C#C
C#4y ago
malkav

Get Enum Description with function

I had a helper function for this at some point, but I lost it..
How can I get the description tag from any enum?
Say I have an enum:
public enum MyEnum
{
  [Description("The first")]First,
  [Description("The Second")]Second,
  // ...
}

and I wanted to get the description values returned, how would I go about it, regardless of Enum I put into the function?
Preferably I would want to call
MyEnum.GetDescription(MyEnum.First)
or something to return
"The First"
Was this page helpful?