public int Addition(int a , int b, int c=10)
{
return a+b+c;
}
in above example c is an optional parameter.
while calling the method, it is optional to pass value for optional parameter.
obj.Add(1,2) would result in 13
Note: We can have optional parameter only after all required parameter. we can't have optional parameter at the beginning or at the middle of any required parameter.
public int Add(int a=5, int b, int c) is invalid.
Similarly,
public int Add(int a, int b=5, int c) is also invalid.