为什么我不能在公共抽象类的方法中使用Linq Where子句?

时间:2013-06-05 08:41:29

标签: c# linq list dictionary where

我有以下构造,我不能使用Where子句作为linq查询的一部分,我想知道为什么:

public abstract class Foo : IFoo
{
    public Foo(List<int> testCollection)
    {
        var result = testCollection.Where(.......).Select(.....);

    }
}

Intellisense不识别Where子句,我也遇到编译错误。这与我试图在抽象类中使用它有关吗?我使用.Net 4.5,我可以在常规类中构建Linq查询。

1 个答案:

答案 0 :(得分:10)

你有using System.Linq;在C#文件的顶部吗? :)