CSharp examples for System:Enum
Get Enum Name Value
using System.Xml.Serialization; using System.Threading.Tasks; using System.Text; using System.Linq; using System.IO;/*from w w w . j a va2 s .c o m*/ using System.Collections.Generic; using System; public class Main{ public static String GetNameValue(Enum value) { var attribute = (XmlEnumAttribute)Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(XmlEnumAttribute)); String result; if (attribute != null) { result = attribute.Name; } else { result = value.ToString(); } return result; } }