Possible Duplicate:
Question about ambiguous calls in C#
I have these two methods:
TypeA MyMethod(string s) {}
TypeB MyMethod(string s) {}
The following call gives me "ambiguity between methods" error:
TypeA ta = MyMethod("some string");
How does this happen when I'm asking for a TypeA
object to return explicitly and not via var
or otherwise?
TypeA
and TypeB
are separate classes, they don't have anything in common.
From the C# spec v4.0, section 1.6.6:
The signature of a method must be unique in the class in which the method is declared. The signature of a method consists of the name of the method, the number of type parameters and the number, modifiers, and types of its parameters. The signature of a method does not include the return type.
You have two methods with the same signature because they differ only in the return type. This is not allowed.