Get Enum Value from String

1
var em = (ChooseEnum) Enum.Parse( typeof(ChooseEnum), desc);

Get DescriptionAttribute from Enum Value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public static string ConvertToSql(Enum value)
{
Type enumType = value.GetType();
string name = Enum.GetName(enumType, value);
if (name != null)
{
FieldInfo fieldInfo = enumType.GetField(name);
if (fieldInfo != null)
{
DescriptionAttribute attribute = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute), false) as DescriptionAttribute;
if (attribute != null)
{
return attribute.Description;
}
}
}

return null;
}

Reference Links: C# Get and Parse DescriptionAttribute of Enum Type
How to get the value corresponding to Enum object from string in C#