1
代码如下所示:
Public Class MasterA
Inherits Underling
End Class
Public Class MasterB
Inherits Underling
End Class
Public Mustinherit Class Underling
Sub DoSomething()
Me.GetType 'Using the instance, I can get the class.
end sub
Shared function() as ???? 'How can I define the return type based on the class that inherited me?
'Me.GetType 'Won't work as this is a shared function with no instance 'Me'
End Function
End class
确定。问题是:有没有办法从另一个类继承的共享函数中获取类类型?
我在构建的是一个XML序列化器/解析器作为一个可继承的类,以便继承它的类可以被嵌套到一个XML文件中,然后再返回。我不想为每种类型的类编写序列化器/反序列化器,我只想继承这些功能。
尽管如此,要求我能够确定在共享函数中继承我的clas。