40 Overloading in VB.NET

Code:

Module Module1

    Class Add
        Dim C As Integer

        Function Sum(ByVal x As Integer, ByVal y As Integer)
            C = x + y
            Console.WriteLine("Addition:" & C)
        End Function

        Function Sum(ByVal x As Integer, ByVal y As Integer, ByVal z As Integer)
            C = x + y + z
            Console.WriteLine("Addition:" & C)
        End Function


    End Class

    Sub Main()
        Dim obj As New Add

        obj.Sum(10, 20)
        obj.Sum(10, 20, 30)
        Console.ReadKey()

    End Sub
End Module





Ouput:

Overloading in VB.NET

Previous
Next Post »