using System.ComponentModel;
public static class Extensions
public static TAttribute GetAttribute<TAttribute>(this Enum enumValue) where TAttribute : Attribute
return enumValue.GetType()
.GetMember(enumValue.ToString())
.GetCustomAttribute<TAttribute>();
public static string GetDisplayName(this Enum enumValue)
return enumValue.GetAttribute<DescriptionAttribute>().Description;
public static string[] GetDisplayNamesList(this Enum enumValue)
return Enum.GetValues(enumValue.GetType())
.Select(v => v.GetDisplayName())