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"); }
C# 获取属性字段上DescriptionAttribute的值,布布扣,bubuko.com
C# 获取属性字段上DescriptionAttribute的值
原文:http://www.cnblogs.com/gossip/p/3738402.html