/// <summary> /// 获取枚举文本内容 /// </summary> /// <typeparam name="TEnum"></typeparam> /// <param name="value"></param> /// <returns></returns> public static string GetEnumDescription(this Enum @enum) { if (@enum == null) { return string.Empty; } Type enumType = @enum.GetType(); var name = Enum.GetName(enumType, @enum); if (name == null) return string.Empty; var descAttr = enumType.GetField(name).GetCustomAttribute<System.ComponentModel.DescriptionAttribute>(); return descAttr != null ? descAttr.Description : string.Empty; }