皆さん。
コードは次のようになります。
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 ファイルにシリアライズして、再び戻すことができます。これを行いたいクラスのタイプごとにシリアライザー/デシリアライザーを作成するのではなく、機能を継承したいと思います。
ただし、そのためには、共有関数で私を継承したクラスを確認できる必要があります。