using System; using System.ComponentModel; using System.Linq; namespace ShakerApp.Tools { public static class EnumHelper { public static string Description(this T e) where T:Enum { if (e == null || !e.GetType().IsEnum) return ""; return (e.GetType()? .GetField(e.ToString())? .GetCustomAttributes(typeof(DescriptionAttribute), false) .FirstOrDefault() as DescriptionAttribute)?.Description ?? e.ToString(); } } }