CSharp examples for System:Enum
Get Enum String Value
using System.Reflection; using System;/* ww w.j a v a2 s .c o m*/ public class Main{ public static string GetStringValue(this Enum value) { Type type = value.GetType(); FieldInfo fieldInfo = type.GetRuntimeField(value.ToString()); StringValueAttribute[] attribs = fieldInfo.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[]; //return the first return attribs.Length > 0 ? attribs[0].Value : null; } }