我在创建一个可以动态创建变量类型对象的子项时遇到了麻烦.这是我正在努力实现的一个例子:
class systemSettings 'some properties end class Class fireSystemSettings inherits systemSettings 'some additional properties end class Class windSystemSettings inherits systemSettings 'some additional properties end class sub createSystem(systemType as Type,arg1 as object,arg2 as object) Dim newSystem as New systemType(arg1,arg2) systemCollection.add(newSystem) end sub
我无法让它发挥作用.我已经做了很多研究,并研究了泛型类型,反射和其他工具,但我无法确定如何最好地解决这个问题.
您正在寻找Activator.CreateInstance(systemType)