How to use class with inheritance in VB.NET

1 Answer

0 votes
Class A
    Public n As Integer

    Public Sub Show()
        Console.WriteLine(n)
    End Sub
End Class

Class B : Inherits A
    Public Sub New(ByVal value As Integer)
        n = value
    End Sub
End Class

Class C : Inherits A
    Public Sub New(ByVal value As Integer)
        n = value
    End Sub
End Class

Module Module1

    Sub Main()

        Dim o1 As B = New B(13)
        o1.Show()

        Dim o2 As C = New C(20)
        o2.Show()

    End Sub

End Module

' run:
' 
' 13
' 20

 



answered Sep 17, 2018 by avibootz

Related questions

...