using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace NXWMS.Code.Extends { /// /// /// public static class EnumExtentions { public static string Description(this Enum t) { string value = t.ToString(); FieldInfo field = t.GetType().GetField(value); object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); if (objs == null || objs.Length == 0) return value; DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0]; return descriptionAttribute.Description; } } }