I have a question on function overloading, Can you please let me know why it is not showing compilation error
class Program
{
static void Main(string[] args)
{
var inputObj = new CalcClass();
Console.WriteLine(inputObj.AddNumber(null, null));
}
}
class CalcClass
{
public double AddNumber(double? a, double? b)
{
return (double)(a ?? 0 + b ?? 0);
}
public short AddNumber(short? a, short? b)
{
return (short)(a ?? 0 + b ?? 0);
}
public int AddNumber(int? a, int? b)
{
return (int)(a ?? 0 + b ?? 0);
}
}
It is executing the public short AddNumber(short? a, short? b)
function even though ambiguous between the class methods