我有一个type变量-type t=typeof(myClass);
type
type t=typeof(myClass);
如何使用类型变量t创建字典-Dictionary?
Dictionary
可以将Activator.CreateInstance与泛型类型一起使用:
var genType = typeof(Dictionary<,>).MakeGeneric(typeof(string), t); var dictionary = Activator.CreateInstance(genType);