Accessing Enum Description in C# :-
code example:-
public enum USERS
{
[Description("TND")]
USER1= 1,
[Description("TND")]
USER2,
[Description("ND")]
USER3,
[Description("ND")]
USER4,
[Description("ND")]
USER5,
[Description("T")]
USER6,
}
public string GetDescriptionFromEnumValue(Enum value)
{
DescriptionAttribute attribute = value.GetType()
.GetField(value.ToString())
.GetCustomAttributes(typeof(DescriptionAttribute), false)
.SingleOrDefault() as DescriptionAttribute;
return attribute == null ? value.ToString() : attribute.Description;
}