方法 : Visual Basic でクラスを継承する
更新 : 2007 年 11 月
この例では、いずれも Shape クラスを継承する、Circle クラスと Rectangle クラスを定義します。また、Rectangle クラスを継承する Square クラスを定義します。
使用例
このコードの例は、IntelliSense コード スニペットとしても利用できます。コード スニペット ピッカーでは、これは [Visual Basic Language] にあります。詳細については、「方法 : コードにスニペットを挿入する (Visual Basic)」を参照してください。
Public Class Shape
' Definitions of properties, methods, fields, and events.
End Class
Public Class Circle : Inherits Shape
' Specialized properties, methods, fields, events for Circle.
End Class
Public Class Rectangle : Inherits Shape
' Specialized properties, methods, fields, events for Rectangle.
End Class
Public Class Square : Inherits Rectangle
' Specialized properties, methods, fields, events for Square.
End Class
コードのコンパイル方法
必要な条件は次のとおりです。
System 名前空間への参照
メモ : 継承元のクラスが NotInheritable として定義されていないことを確認してください。