Shadow member variable in base class : Member Fields « Class Module « VB.Net Tutorial






Module Module1

    Class BaseClass
        Public Name As String
        Public Amount As Integer
        Public Message As String

        Public Sub New(ByVal Name As String, ByVal Amount As Integer, ByVal Message As String)
            Me.Name = Name
            Me.Amount = Amount
            Me.Message = Message
        End Sub

        Public Sub ShowBaseMembers()
            Console.WriteLine("Name: " & Name)
            Console.WriteLine("Amount: " & Amount)
            Console.WriteLine("Message: " & Message)
        End Sub
    End Class

    Class DerivedClass
        Inherits BaseClass

        Public Amount As Double
        Public Shadows Message As String

        Public Sub ShowDerivedMembers()
            Console.WriteLine("Name: " & Name)
            Console.WriteLine("Amount: " & Amount)
            Console.WriteLine("Message: " & Message)
        End Sub

        Public Sub New(ByVal Name As String, ByVal Amount As Integer, ByVal Message As String)
            MyBase.New(Name, Amount, Message)
        End Sub

    End Class

    Sub Main()

    End Sub

End Module








6.12.Member Fields
6.12.1.Shadow member variable in base class
6.12.2.Shadow fields
6.12.3.Shared field
6.12.4.Field initialization
6.12.5.Public Field