To get the value of a Description attribute from an enumeration value using reflection in C#, you need to do the following steps:
GetType() method.FieldInfo object for the enumeration value using the GetField() method.DescriptionAttribute object for the FieldInfo object using the GetCustomAttribute() method.Description property from the DescriptionAttribute object.Here's the code to get the Description attribute value from an enum using reflection:
main.cs520 chars17 linesTo use the above extension method, simply call it using an instance of the enum:
main.cs75 chars3 lines
gistlibby LogSnag