匿名类的反射 属性描述器

ArrayList arrayList = new ArrayList { new { ID = "119", Name = "csdn" } };
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(arrayList[0]);
PropertyDescriptor pdID = pdc.Find("ID", true);
PropertyDescriptor pdName = pdc.Find("Name", true);
for (int i = 0; i < 5000 * 100000; i++)
{

var item = arrayList[0];


var id = pdID.GetValue(item);


var name = pdName.GetValue(item);

}

posted on 2015-10-05 13:33  听哥哥的话  阅读(273)  评论(0编辑  收藏  举报

导航