컴파일러 오류 CS0473

업데이트: 2007년 11월

오류 메시지

명시적 인터페이스 구현 'method name'에 인터페이스 멤버가 두 개 이상 일치합니다. 실제로 선택되는 인터페이스 멤버는 구현에 따라 다릅니다. 대신 비명시적 구현을 사용해 보십시오.
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.

경우에 따라 제네릭 메서드에서 제네릭이 아닌 메서드의 시그니처와 동일한 시그니처를 사용할 수 있습니다. 문제는 CLI(공용 언어 인프라) 메타데이터 시스템에서 메서드가 어떤 슬롯에 바인딩할지 명확히 나타낼 방법이 없다는 데 있습니다. 이러한 결정은 CLI이 해야 합니다.

참고:

이 오류는 Visual Studio 2005에서는 발생하지 않았지만 Visual Studio 2008에서는 발생합니다.

이 오류를 해결하려면

  • 명시적 구현을 제거하고 암시적 구현 public int TestMethod(int)에서 두 인터페이스 메서드를 모두 구현하도록 지정합니다.

예제

다음 코드에서는 CS0473 오류가 발생하는 경우를 보여 줍니다.

// cs0473.cs
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;
    }
}

참고 항목

기타 리소스

Fabulous Adventures in Coding