首页 > 代码库 > c#反射

c#反射

int count = Convert.ToInt32(objType.GetProperty("Count").GetValue(value, null));

var ss= objType.GenericTypeArguments[0];
var listType = typeof(List<>).MakeGenericType(ss);
var list = Activator.CreateInstance(listType);
var addMethod = listType.GetMethod("Add");

 

object oItem = objType.GetProperty("Item").GetValue(value, new object[] { i });
object obj = Copy(oItem);
addMethod.Invoke((object)list, new object[] { obj });

c#反射