I have a class with a static method, like so:
public class Calculator
{
public static decimal Calculate(decimal op1, decimal op2) => op1 * op2;
}
I add an instance method to that class which calls that static method:
public decimal Foo(decimal op1, decimal op2)
{
return Calculate(op1, op2);
}
This compiles just fine. Now I add another instance method which calls that static method inside a local function:
public decimal Bar((decimal op1, decimal op2) pair)
{
return Calculate();
decimal Calculate()
{
return Calculate(pair.op1, pair.op2);
}
}
This gives the compile error
CS1501 No overload for method 'Calculate' takes 2 arguments
If I change the call to return Calculator.Calculate(pair.op1, pair.op2)
or give the
local function a different name it compiles without error. Why?