Before going to know all about method overloading, i want to say
where it is exactly comes into picture. Lot of
programming languages supports default or optional parameters.
Example Vb.Net supports optional parameters.
In C#.Net, there is no such type of facility to declare optional
parameters as we like.
somemethod (a as Integer, b as Integer, optionalc
Then this Method overloading concept will be the useful one to
overcome this type of problems.
From Framework 4.0 onwards optional parameters are available.
Definition is using the same method name with different type
of parameters or different set of parameters is known as Method Overloading.
For example, you want to declare a method with name Addition.
But you don't have idea about how many parameters has to declare means addition
of two numbers or three numbers or etc, and you don't know about what type of
data it is? means Int, float or etcÃ¢â‚¬Â¦.
See the below code to understand easily:
public int Addition(int a, int b)
public int Addition(int a, int b,int c)
= a + b+ c;
public float Addition(float a, float b)
= a + b;
public float Addition(float a, float b, float c)
= a + b+ c;
//Now you can use those Addition method four types
public static void Main(String
= new Method_overloading();
of two integers::::::::::::::::" + mthover.Addition(2,
of two double type values::::::" + mthover.Addition(0.40f,
of three integers::::::::::::::" + mthover.Addition(2,
of three double type values::::" + mthover.Addition(0.40f,