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 });

相关文章:

  • 2022-12-23
  • 2021-06-05
  • 2021-08-15
  • 2021-11-07
  • 2022-01-28
  • 2022-02-13
  • 2021-08-10
猜你喜欢
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2021-07-20
相关资源
相似解决方案