Compiler Error CS0473
Explicit interface implementation 'method name' matches more than one interface member. Which interface member is actually chosen is implementation-dependent. Consider using a non-explicit implementation instead.
In some cases a generic method might acquire the same signature as a non-generic method. The problem is that there is no way in the common language infrastructure (CLI) metadata system to unambiguously state which method binds to which slot. It is up to the CLI to make that determination.
To correct this error
To correct the error, eliminate the explicit implementation and implement both of the interface methods in the implicit implementation public int TestMethod(int)
.
Example
The following code generates CS0473:
public interface ITest<T>
{
int TestMethod(int i);
int TestMethod(T i);
}
public class ImplementingClass : ITest<int>
{
int ITest<int>.TestMethod(int i) // CS0473
{
return i + 1;
}
public int TestMethod(int i)
{
return i - 1;
}
}
class T
{
static int Main()
{
ImplementingClass a = new ImplementingClass();
if (a.TestMethod(0) != -1)
return -1;
ITest<int> i_a = a;
System.Console.WriteLine(i_a.TestMethod(0).ToString());
if (i_a.TestMethod(0) != 1)
return -1;
return 0;
}
}
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for