Given:
interface IFoo
{
void Print(string text = "abc");
}
class Bar : IFoo
{
public void Print(string text = "def")
{
Console.WriteLine(text);
}
}
class Program
{
static void Main(string[] args)
{
Bar b = new Bar();
b.Print();
IFoo f = b as IFoo;
f.Print();
}
}
The output is:
def
abc
Is just me or this is a little odd? Initially I was expecting "def" in both cases. However, if that would be the case then the optional argument abstract methods would be useless. But still seems like a good starting point for nasty bugs.