CSharp examples for System:Enum
Field Name from Enum
using System.Threading.Tasks; using System.Text; using System.Reflection; using System.Linq; using System.Collections.Generic; using System;/*from ww w. j a va 2 s . co m*/ public class Main{ /// <exclude/> public static string FieldName(this Enum value) { var attr = value.GetType().GetField(value.ToString()).GetCustomAttribute<NameFieldAttribute>(); return attr != null ? attr.Name : null; } }