41 Overriding in VB.NET

Code:

Module Module1

    Class Employee
        Dim sal As Long

        Overridable Function Accept(ByVal bs As Integer, ByVal b As Integer)
            sal = bs + b
            Console.WriteLine("Salary: " & sal)
        End Function

    End Class

    Class Emp
        Inherits Employee

        Overloads Function Accept(ByVal n As String, ByVal bs As Long, ByVal b As Long, ByVal age As Integer)
            Console.WriteLine("Name: " & n)
            Console.WriteLine("Basic Salary: " & bs)
            Console.WriteLine("Bonous: " & b)
            Console.WriteLine("Age: " & age)
        End Function

    End Class

    Sub Main()
        Dim e As New Emp()

        e.Accept("Coding Atharva", 30000, 10000, 16)
        e.Accept(30000, 10000)
        Console.ReadKey()
    End Sub
End Module





Ouput:

Overriding in VB.NET


Previous
Next Post »