熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP.NET入門教程 9.4.2 繼承[2]

2022-06-13   來源: .NET編程 

    ()在同一個文件中創建另一個類Car:

 

Public Class Car

    Inherits Vehicle

    Public Sub New()

        _wheels =

        _topSpeed =

        _warningSound = Honk

    End Sub

End Class

    ()現在再創建另一個類Bike:

 

Public Class Bike

    Inherits Vehicle

    Public Sub New()

        _wheels =

        MyBaseTopSpeed =

        _warningSound = Ring Ring

    End Sub

End Class

    ()繼續創建另一個類Skateboard:

 

Public Class Skateboard

    Inherits Vehicle

    Public Sub New()

        _wheels =

        _topSpeed =

    End Sub

    Public Overrides Function Warning() As String

        Return No warning youll have to shout yourself

    End Function

End Class

    在End Sub和End Class之間輸入以下代碼

    Public Overrides

    現在按下空格鍵可以看到彈出了一個小小的幫助提示

[]  []  []  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/14582.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.