Overloading in visual basic.net is the method by which a property or a method takes different forms at different instances. It can also be termed as "Polymorphism".
Example:
Module Module1
Public Class mul
Public a, b As Integer
Public c, d As Double
Public Function mul(ByVal a As Integer) As Integer
Return a
End Function
Public Function mul(ByVal a As Integer,
ByVal b As Integer) As Integer
Return a * b
End Function
Public Function mul(ByVal d As Double,
ByVal c As Double) As Double
Return d * c
End Function
End Class
Sub Main()
Dim res As New mul
System.Console.WriteLine
("Overloaded Values of Class Mul is::")
System.Console.WriteLine(res.mul(10))
System.Console.WriteLine(res.mul(20, 10))
System.Console.WriteLine(res.mul(12.12, 13.23))
Console.Read()
End Sub
End Module
Output:
Overloaded values of Class Mul is:
10
200
160.3476
No comments:
Post a Comment