Share via


컴파일러 오류 CS0415

업데이트: 2007년 11월

오류 메시지

'IndexerName' 특성은 명시적 인터페이스 멤버 선언이 아닌 인덱서에서만 사용할 수 있습니다.
The 'IndexerName' attribute is valid only on an indexer that is not an explicit interface member declaration

이 오류는 인터페이스의 명시적 구현이었던 인덱서에서 IndexerName 특성을 사용하는 경우에 발생합니다. 가능한 경우 인덱서 선언에서 인터페이스 이름을 제거하여 이 오류를 해결할 수도 있습니다. 자세한 내용은 IndexerNameAttribute 클래스를 참조하십시오.

다음 샘플에서는 CS0415 오류가 발생하는 경우를 보여 줍니다.

// CS0415.cs
using System;
using System.Runtime.CompilerServices;

public interface IA
{
    int this[int index]
    {
        get;
        set;
    }
}

public class A : IA
{
    [IndexerName("Item")]  // CS0415
    int IA.this[int index]
    // Try this line instead:
    // public int this[int index]
    {
        get { return 0; }
        set { }
    }

    static void Main()
    {
    }
}