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