/// <summary> /// 获取枚举文本内容 /// </summary> /// <param name="enum"></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; }