C#反射创建List实体

string className = "Person";

string namespaceStr = "ConsoleApplication1";

var model = Assembly.GetExecutingAssembly().CreateInstance(string.Join(".", new object[] { namespaceStr, className }));

var modelList = Activator.CreateInstance(typeof(List<>).MakeGenericType(new Type[] { model.GetType() }));

var addMethod = modelList.GetType().GetMethod("Add");

addMethod.Invoke(modelList, new object[] { model });