컴파일러 오류 CS1624

업데이트: 2007년 11월

오류 메시지

'type'이(가) 반복기 인터페이스 형식이 아니므로 'accessor'의 본문은 반복기 블록이 될 수 없습니다.
The body of 'accessor' cannot be an iterator block because 'type' is not an iterator interface type

This error occurs if an iterator accessor is used but the return type is not one of the iterator interface types: IEnumerable, IEnumerable<T>, IEnumerator, IEnumerator<T>. 이 오류가 발생하지 않도록 하려면 반복기 인터페이스 형식 중 하나를 반환 형식으로 사용합니다.

예제

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

// CS1624.cs
using System;
using System.Collections;

class C
{
    public int Iterator
    // Try this instead:
    // public IEnumerable Iterator
    {
        get  // CS1624
        {
            yield return 1;
        }
    }
}