如何使用动态对象类型创建通用List
我想创建一个Type对象的通用列表。
我有 …
Type type = typeof(Foo); object model = GetModel();
现在我要创建一个new List((Foo)model)
这可能在C#中吗?
Type listT = typeof(List<>).MakeGenericType(new[]{type}); object list = Activator.CreateInstance(listT);