using System.ComponentModel; namespace System { public static class EnumExtension { public static string GetDescription(this T value) where T : Enum { var field = value.GetType().GetField(value.ToString()); if (field == null) return null; object[] objs = field.GetCustomAttributes(typeof(DescriptionAttribute), false); if (objs.Length == 0) return value.ToString(); DescriptionAttribute descriptionAttribute = (DescriptionAttribute)objs[0]; return descriptionAttribute.Description; } } }