我有一个类似于下面的示例设置我想要定义变量(var1)基于一些信息,当它被实例化时传递到类中。我怎么做?如何有条件地定义变量?
Public Class myClass
Private var1 as someClass
Public Sub New(which_type as string)
if which_type = "a" then
' I need var to be a certain type of class
var1 = new SomeClass()
elseif which_type = "b" then
' I need var1 to be a different type of class
var1 = new SomeOtherClass()
end if
End Sub
End Class
var1只能是一个或另一个......除非从另一个继承 – Plutonix