using System;using System.Collections.Generic;using System.ComponentModel;using System.Reflection;using System.Text;namespace JFJT.GemStockpiles.Helpers{ public static class EnumHelper { ////// 根据值得到中文备注 /// /// /// ///public static String GetEnumDesc(this Type e, int? value) { FieldInfo[] fields = e.GetFields(); for (int i = 1, count = fields.Length; i < count; i++) { if ((int)System.Enum.Parse(e, fields[i].Name) == value) { DescriptionAttribute[] EnumAttributes = (DescriptionAttribute[])fields[i]. GetCustomAttributes(typeof(DescriptionAttribute), false); if (EnumAttributes.Length > 0) { return EnumAttributes[0].Description; } } } return ""; } }}
调用