ExtensionMethod.NET Home of 828 C#, Visual Basic, F# and Javascript extension methods

Get Enum Description

Gets the description of any Enum value.


public static string GetDescriptionFromEnumValue(Enum value)
    DescriptionAttribute attribute = value.GetType()
        .GetCustomAttributes(typeof(DescriptionAttribute), false)
        .SingleOrDefault() as DescriptionAttribute;
    return attribute == null ? value.ToString() : attribute.Description;


var enumDescription= Extensions.GetDescriptionFromEnumValue(CalendarEventDescription.DurationStartDate);

Author: Ufuk Zimmerman

Submitted on: 29 mei 2020

Language: csharp

Type: System.Enum

Views: 3543