http://www.cnblogs.com/happyday56/archive/2013/12/03/3456195.html
var ent = new Ent();
foreach (var item in ent.GetType().GetProperties())
{
var v = (DescriptionAttribute[])item.GetCustomAttributes(typeof(DescriptionAttribute), false);
var descriptionName = v[0].Description;
item.SetValue(ent,descriptionName+":1");
}
public enum AccountType
{
[Description("支付宝充值")]
ALIPAY = 1,
[Description("银联充值")]
UNIONPAY = 2
}
public static string GetEnumName<T>(int value) where T : new()
{
Type t = typeof(T);
foreach (MemberInfo mInfo in t.GetMembers())
{
if (mInfo.Name == t.GetEnumName(value))
{
foreach (Attribute attr in Attribute.GetCustomAttributes(mInfo))
{
if (attr.GetType() == typeof(DescriptionAttribute))
{
return ((DescriptionAttribute)attr).Description;
}
}
}
}
return "";
}