public class Calculator
{
public int Add(int a, int b)
{
return a + b;
}
public int Add(int a, int b, int c)
{
return a + b + c;
}
public double Add(double a, double b)
{
return a + b;
}
}
Depending on the number and type of arguments, the correct method is called, despite having the same name.
Calculator calc = new Calculator();
calc.Add(1, 2);
calc.Add(1, 2, 3);
calc.Add(1.5, 2.5);