Function Overloading/Method Overloading: In Function Overloading we can define many methods with the same name but different parameters. It is used when methods require to perform similar tasks but with different parameters.

Step 1

Open your Visual Studio. By pressing Ctrl +Shift + N you will get your “New Project” Window.

Console Application

Figure 1 Console Application

Step 2

After pressing OK you will get into your Coding Part where you will see three files in Solution Explorer [Properties, References, Program.cs], in which Program.cs file is your main file where you embed all your Inheritance program code.

Solution Explorer
Figure 2 Solution Explorer

This is your Function Overloading Program.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Method_overloading32
  6. {
  7. class shape
  8. {
  9. public void Area(int side)
  10. {
  11. int squarearea = side * side;
  12. Console.WriteLine("The Area of Square is :" + squarearea);
  13. }
  14. public void Area(int length, int breadth)
  15. {
  16. int rectarea = length * breadth;
  17. Console.WriteLine("The Area of Rectangle is :" + rectarea);
  18. }
  19. public void Area(double radius)
  20. {
  21. double circlearea = 3.14 * radius * radius;
  22. Console.WriteLine("The Area of Circle is :" + circlearea);
  23. }
  24. }
  25. class Program
  26. {
  27. static void Main(string[] args)
  28. {
  29. shape s = new shape();
  30. s.Area(10);
  31. s.Area(10, 20);
  32. s.Area(10.8);
  33. Console.ReadKey();
  34. }
  35. }
  36. }
Different Parameters

Figure 3 Different Parameters

OUTPUT

By Pressing F5 you will get your Output like this

Output

Figure 4 Output

Hope you like it! Have a nice day. Thank you for Reading!