컴파일러 오류 CS1623

업데이트: 2007년 11월

오류 메시지

반복기에는 ref 또는 out 매개 변수를 사용할 수 없습니다.
Iterators cannot have ref or out parameters

이 오류는 반복기 메서드에 ref 또는 out 매개 변수를 사용하는 경우에 발생합니다. 이 오류가 발생하지 않도록 하려면 메서드 시그니처에서 ref 또는 out 키워드를 제거합니다.

예제

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

// CS1623.cs
using System.Collections;

class C : IEnumerable
{
    public IEnumerator GetEnumerator()
    {
        yield return 0;
    }

    // To resolve the error, remove ref
    public IEnumerator GetEnumerator(ref int i)  // CS1623
    {
        yield return i;
    }

    // To resolve the error, remove out
    public IEnumerator GetEnumerator(out float f)  // CS1623
    {
        f = 0.0F;
        yield return f;
    }
}