How to get the Display Name Attribute of an Enum member via MVC Razor code?
One liner – Fluent syntax public static class Extensions { /// <summary> /// A generic extension method that aids in reflecting /// and retrieving any attribute that is applied to an `Enum`. /// </summary> public static TAttribute GetAttribute<TAttribute>(this Enum enumValue) where TAttribute : Attribute { return enumValue.GetType() .GetMember(enumValue.ToString()) .First() .GetCustomAttribute<TAttribute>(); } } Example public enum … Read more