using System; using System.ComponentModel; using System.Reflection; namespace ServerComm { public static class EnumHelper { // 获取枚举的字符串描述 public static string GetEnumDescription(Enum value) { var field = value.GetType().GetField(value.ToString()); if (field == null) return ""; var attribute = field.GetCustomAttribute(); return attribute == null ? value.ToString() : attribute.Description; } } }