Ejemplo n.º 1
0
 /// <summary>
 /// 通过枚举值取枚举 EnumDescriptionAttribute 描述
 /// </summary>
 /// <param name="enumCode"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static string GetItemDescriptionByValue(this Enum enumCode, int value)
 {
     foreach (var enObj in Enum.GetValues(enumCode.GetType()))
     {
         if (value == (int)enObj)
         {
             return(EnumDescriptionAttribute.GetFieldText(enObj));
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取枚举 EnumDescriptionAttribute 描述
 /// </summary>
 /// <param name="enumCode"></param>
 /// <returns></returns>
 public static string ToFullDescription(this Enum enumCode)
 {
     return(string.Format("{0}: {1}", enumCode, EnumDescriptionAttribute.GetFieldText(enumCode)));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取枚举 EnumDescriptionAttribute 描述
 /// </summary>
 /// <param name="enumCode"></param>
 /// <returns></returns>
 public static string ToDescription(this Enum enumCode)
 {
     return(EnumDescriptionAttribute.GetFieldText(enumCode));
 }