VB.Net Program to Demonstrate the Method Overloading Based on a Different Order of Arguments

You are currently viewing VB.Net Program to Demonstrate the Method Overloading Based on a Different Order of Arguments

VB.Net program to demonstrate the method overloading based on a different order of arguments

'VB.net program to demonstrate the method -overloading based 
'on a different order of arguments.

Module Module1
    Class Sample
        Public Sub Add(ByVal num1 As Double, ByVal num2 As Integer)
            Dim sum As Double = 0

            sum = num1 + num2
            Console.WriteLine("Sum is: {0}", sum)
        End Sub

        Public Sub Add(ByVal num1 As Integer, ByVal num2 As Double)
            Dim sum As Double = 0

            sum = num1 + num2
            Console.WriteLine("Sum is: {0}", sum)
        End Sub
    End Class
    
    Sub Main()
        Dim obj As New Sample()

        obj.Add(10.6, 20)
        obj.Add(10, 20.8)
    End Sub
End Module

Output

Sum is: 30.6
Sum is: 30.8
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply