컴파일러 오류 CS0631

업데이트: 2007년 11월

오류 메시지

이 컨텍스트에서는 ref 및 out을 사용할 수 없습니다.
ref and out are not valid in this context

인덱서를 선언할 때에는 ref 또는 out 매개 변수를 사용할 수 없습니다.

예제

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

// CS0631.cs
public class MyClass
{
    public int this[ref int i]   // CS0631
    // try the following line instead
    // public int this[int i]
    {
        get
        {
            return 0;
        }
    }
}

public class MyClass2
{
    public static void Main()
    {
    }
}