更新:2007 年 11 月
错误消息
找不到源类型“type”的查询模式的实现。未找到“method”。请考虑显式指定范围变量“name”的类型。
如果查询表达式指定了没有为其实现任何标准查询运算符的数据源,则会生成此错误。生成此错误的一种方式是在没有为范围变量指定显式类型的情况下指定 ArrayList。
更正此错误
在下面的示例中,只需指定范围变量的类型即可解决该问题:
var q = from int x in list
示例
下面的示例演示一种生成 CS1934 的方式:
// cs1934.cs
using System.Linq;
using System.Collections;
static class Test
{
public static void Main()
{
var list = new ArrayList { 0, 1, 2, 3, 4, 5 };
var q = from x in list // CS1934
select x + 1;
}
}