Get description of optionSet

Enumeration :

public enum Country

Tunisia = 1,

France = 2,

UnitedState = 3,

To get the description of enumeration :

public static string GetDescriptionFromEnumValue(Enum value)
if (value == null)
return null;
var fieldInfo = value.GetType().GetField(value.ToString());
if(fieldInfo == null)
{ return null;
DisplayAttribute attribute = fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false).SingleOrDefault() as DisplayAttribute;
return attribute.Description;
//if the value of enum doesn't exist
catch (Exception ex)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s