Assembly assembly = cr.CompiledAssembly;
object instance = assembly.CreateInstance("Models.Test", true, BindingFlags.Default, null, null, null, null);
Type instType = instance.GetType();
instType.GetProperty("Code").SetValue(instance, "Code_value", null);
instType.GetProperty("Name").SetValue(instance, "Name_value", null);
instType.GetProperty("Address").SetValue(instance, "Address_value", null);
var listType = typeof(List<>);
var genericListType = listType.MakeGenericType(instType);
var instGenericListType = (IList)Activator.CreateInstance(genericListType);
instGenericListType.Add(instance);
我有IList
,现在我要转换List<Models.Test>
,我该怎么做?当我致电MakeGenericType