Type type = typeof(对象); //获取类型
var userActivityModel = (对象)Activator.CreateInstance(type); //创建对象
foreach (var item in model.ChildControl)
{
int index = 0;
foreach (var Prop in type.GetProperties())
{
if (index == 1)
{
break;
}
if (Prop.Name == item.fileName)
{
Prop.SetValue(userActivityModel, item.content);//设置值
index = 1;
break;
}
}
}
标签:反射,index,userActivityModel,Prop,item,var,type
From: https://www.cnblogs.com/sylAll/p/17475599.html