I want to create a new XElement or XAttribute using an enum that stores the values. The constructor of both classes expects XName as name and object as content. This means that I can pass an enum as content but I need to use ToString() to use it in the name. Note that XName has an implicit operator for string.
This works:
new XElement(HttpStatusCode.Accepted.ToString(), (int)HttpStatusCode.Accepted)
new XElement(HttpStatusCode.Accepted.ToString(), HttpStatusCode.Accepted)
This doesn't work:
new XElement(HttpStatusCode.Accepted, (int)HttpStatusCode.Accepted)
Any suggestions how an enum can be for setting the name of an XElement?
Thanks.