EnumHelper.cs 379 B

123456789
  1. using System.ComponentModel;
  2. public class EnumHelper {
  3. public static string GetDescription(Enum value) {
  4. var field = value.GetType().GetField(value.ToString());
  5. var attributes = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false);
  6. return attributes.Length > 0 ? attributes[0].Description : value.ToString();
  7. }
  8. }