⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parentderivedclasses.vb

📁 Mastering VBNet Include Source Code
💻 VB
字号:
Option Strict On
Public MustInherit Class ParentClass
    Public Overridable Function Method1() As String
        Return ("I'm the original Method1")
    End Function

    Protected Function Method2() As String
        Return ("I'm the original Method2")
    End Function

    Public Function Method3() As String
        Return ("I'm the original Method3")
    End Function

    Public MustOverride Function Method4() As String
    ' NO CODE IN A MEMBER THAT MUST BE OVERRIDDEN !
    ' NOTICE THE LACK OF THE MATHING END FUNCTION HERE

    Public Function Method5() As String
        Return ("I'm the original Method5")
    End Function

    Private prop1, prop2 As String
    Property Property1() As String
        Get
            Property1 = "Original Property1"
        End Get
        Set(ByVal Value As String)
            prop1 = Value
        End Set
    End Property

    Property Property2() As String
        Get
            Property2 = "Original Property2"
        End Get
        Set(ByVal Value As String)
            prop2 = Value
        End Set
    End Property

End Class

Public Class DerivedClass
    Inherits ParentClass
    Overrides Function Method4() As String
        Return ("I'm the derived Method4")
    End Function

    Public Function newMethod() As String
        Console.WriteLine("<This is the derived Class's newMethod calling Method2 of the parent Class> ")
        Console.WriteLine("    " & MyBase.Method2())
    End Function
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -