One of my colleagues find this odd case. I post here a simple example:
using System;
namespace Test
{
public class F
{
public void f(double d) { Console.WriteLine("public void F.f(double d)"); }
public virtual void f(long l, int q = 0) { Console.WriteLine("public virtual void F.f(long l, int q = 0)"); }
}
public class FDerived : F
{
public override void f(long l, int q) { Console.WriteLine("public override FDerived.f(long l, int q)"); }
public void g() { f(2L); }
}
public class G : FDerived
{
public void h1() { F fd = new FDerived(); fd.f(2L); }
public void h2() { FDerived fd = new FDerived(); fd.f(2L); }
}
class Program
{
static void Main(string[] args)
{
new FDerived().g();
new G().h1();
new G().h2();
Console.ReadLine();
}
}
}
The output of the example is:
public void F.f(double d)
public override FDerived.f(long l, int q)
public void F.f(double d)
I don't see how this can make sense.
Why does f(double) is a better match than f(long, int=0) for f(long)? And why does it depend on the type of 'fd'?!