How does the compiler choose which method to call when a parameter type is ambiguous?
- by Darksider
I have the following code:
[TestMethod]
public void TestFoo()
{
Foo(null);
}
private void Foo (object bar)
{
Console.WriteLine("Foo - object");
}
private void Foo (string bar)
{
Console.WriteLine("Foo - string");
}
and when I run the test "TestFoo()", the console output is "Foo - string". How does the compiler decide which method to call?