using System.ComponentModel; namespace Seyounth.Core.Extensions; public static class EnumHelper { public static IEnumerable GetValues() { return Enum.GetValues(typeof(T)).Cast(); } // 获取枚举值的描述信息 public static string GetDescription(this T enumValue) where T : Enum { var fieldInfo = enumValue.GetType().GetField(enumValue.ToString()); var descriptionAttributes = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[]; return descriptionAttributes is { Length: > 0 } ? descriptionAttributes[0].Description : enumValue.ToString(); } }