HOW TO:在 Visual Basic 中自類別繼承
更新:2007 年 11 月
本範例會定義 Circle 和 Rectangle 類別 (這兩個類別都繼承自 Shape 類別) 以及 Square 類別 (其繼承自 Rectangle 類別)。
範例
這個程式碼範例也可以當做 IntelliSense 程式碼片段使用。在程式碼片段選擇器中,這個程式碼片段位於 [Visual Basic 語言] 中。如需詳細資訊,請參閱 HOW TO:在您的程式碼中插入程式碼片段 (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。