Example 1: Implementation of C# method overloading (static polymorphism)
Program.cs
Console.WriteLine("Area of Rectangle "+Shape.Rectangle(5,10));Console.WriteLine("Area of Rectangle {0}",Shape.Rectangle(3.14,10));classShape{publicstaticintRectangle(inta,intb){returna*b;}publicstaticdoubleRectangle(doublea,doubleb){returna*b;}}
Output
kodingwindow@kw:~/csharp$ dotnet run
Area of Rectangle 50
Area of Rectangle 31.400000000000002
kodingwindow@kw:~/csharp$
Example 2: Implementation of C# method overloading
Program.cs
Shapes=newShape();doublearea=s.Square(10);Console.WriteLine("Area of Square "+area);area=s.Rectangle(3.14,10);Console.WriteLine("Area of Rectangle {0}",area);classShape{publicdoubleSquare(inta){returna*a;}publicdoubleRectangle(doublea,doubleb){returna*b;}}
Output
kodingwindow@kw:~/csharp$ dotnet run
Area of Square 100
Area of Rectangle 31.400000000000002
kodingwindow@kw:~/csharp$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.