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的值
时间: 2024-11-10 06:53:52