WAP to demonstrate Polymorphism in Vb.net through Method Overloading
Demonstratation of Polymorphism in Vb.net through Method Overloading :
code begins :
Imports System.Console Module Module1 Sub areas(ByVal side As Integer) Dim area As Integer area = side * side WriteLine("Area of Square : " & area) End Sub Sub areas(ByVal l As Integer,ByVal b As Integer) Dim area As Integer area = l * b WriteLine("Area of Rectangle : " & area) End Sub Sub areas(ByVal r As Double) Dim area As Double area = 4.13 * r * r WriteLine("Area of Circle : " & area) End Sub Sub Main() Dim l, b, ch As Integer Dim r As Double WriteLine("1. Area of a Square") WriteLine("2. Area of a Rectange") WriteLine("3. Area of a Circle") WriteLine("Enter Your Choice : ") ch = ReadLine() Select Case ch Case 1 Write("Enter Size of a side : ") l = ReadLine() areas(l) Case 2 Write("Enter length : ") l = ReadLine() Write("Enter breadth : ") b = ReadLine() areas(l, b) Case 3 Write("Enter radius : ") r = ReadLine() areas(r) Case Else WriteLine("Enter a Valid Choice") End Select End Sub End Module