컴파일러 오류 CS1943
업데이트: 2007년 11월
오류 메시지
형식이 'type'인 식은 소스 형식이 'type'인 쿼리 식의 후속 from 절에서 사용할 수 없습니다. 'method' 호출 시 형식을 유추하지 못했습니다.
An expression of type 'type' is not allowed in a subsequent from clause in a query expression with source type 'type'. Type inference failed in the call to 'method'.
모든 범위 변수는 쿼리 가능한 형식을 나타내야 합니다.
이 오류를 해결하려면
형식이 IEnumerable, IEnumerable<T> 또는 파생 인터페이스를 구현하는 쿼리 가능한 형식이거나 쿼리 패턴이 정의되어 있는 다른 형식인지 확인하십시오.
형식이 제네릭이 아닌 IEnumerable이면 범위 변수에 명시적 형식을 제공합니다.
예제
다음 코드에서는 CS1943 오류가 발생하는 경우를 보여 줍니다.
// cs1943.cs
using System.Linq;
class Test
{
class TestClass
{ }
static void Main()
{
int[] nums = { 0, 1, 2, 3, 4, 5 };
TestClass tc = new TestClass();
var x = from n in nums
from s in tc // CS1943
select n + s;
}
}