weh have 2 overloaded methods
public int Add(int a,int b)
{
return a+b;
}
public int Add(int a,int b,int c)
{
return a+b+c;
}
Why to use Method over loading if we can do it in another way like :
Now Look at below:
weh have 2 overloaded methods
public int Addtwo(int a,int b)
{
return a+b;
}
public int Addthree(int a,int b,int c)
{
return a+b+c;
}
in My second example we can do the same operation as we did in first Example,so what is need of overloading the methon ,Please explain.
I had faced this question in interview,but unable to answer.