다음을 통해 공유


'<typename>' 형식은 'System.Collections.Generic.IEnumerable(Of T)'의 여러 인스턴스를 구현하므로 이 형식의 'For Each'가 모호합니다.

업데이트: 2007년 11월

'For Each' on type '<typename>' is ambiguous because the type implements multiple instantiations of 'System.Collections.Generic.IEnumerable(Of T)'

For Each 문이 둘 이상의 GetEnumerator 메서드를 포함하는 반복기 변수를 지정합니다.

반복기 변수는 .NET Framework의 Collections 네임스페이스 중 하나에서 System.Collections.IEnumerable 또는 System.Collections.Generic.IEnumerable<T> 인터페이스를 구현하는 형식이어야 합니다. 각 구문에 대해 다른 형식 인수를 사용하여 클래스에 둘 이상의 생성된 제네릭 인터페이스를 구현할 수 있습니다. 이런 식으로 구현하는 클래스가 반복기 변수에 사용되면 해당 변수는 GetEnumerator 메서드를 둘 이상 포함하게 됩니다. 이런 경우 Visual Basic에서는 호출할 메서드를 선택할 수 없습니다.

오류 ID: BC32096

이 오류를 해결하려면

  • DirectCast 또는 TryCast를 사용하여 반복기 변수 형식을 사용할 GetEnumerator 메서드를 정의하는 인터페이스로 캐스팅합니다.

참고 항목

개념

Visual Basic의 인터페이스 구현 예제

참조

For Each...Next 문(Visual Basic)