In this article, I’m trying to explain the concept of method overloading.Method overloading is the concept of polymorphism which means one name multiple forms. It defines that method can have same name with different parameters or signatures. It allows you to have same name method in one class. In method overloading, method performs different tasks at the different input parameters.
Method overloading requires:
1 - Same method name.
2 - Number of parameters should be different.
3 - Types of parameters should be different.
To implement the method overloading, the methods must have same name and the numbers of parameters or data types of parameters must be different, having different return types of method does not make the method overloaded.
/// mehtod area(int side) for calculating the area of square
/// <param name="side">side of square</param>
public void area(int side)
int z = side * side;
Console.WriteLine("Area Of Square : "+z);
/// mehtod area(int length,int width) for calculating the area of rectangle
/// <param name="length">length of rectangle</param>
/// <param name="width">width of rectangle</param>
public void area(int length,int width)
int z = length * width;
Console.WriteLine("Area Of Rectangle : " + z);
static void Main(string args)
MethodOverloading mth = new MethodOverloading();//Create object
Area Of Square : 16
Area Of Rectangle : 35
In this example, i have created two methods with the name area() - one for calculating the area of square and another for rectangle, note that both the methods have same name but different number of parameters which make the methods overloaded.