【问题标题】:Why I cannot use the Linq Where clause in a method of a public abstract class?为什么我不能在公共抽象类的方法中使用 Linq Where 子句?
【发布时间】:2013-06-05 08:41:29
【问题描述】:

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

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

    }
}

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

【问题讨论】:

  • 文件顶部有using System.Linq 指令吗?没有其他明显的原因无法识别它......
  • @Trustme-I'maDoctor,愚蠢的我。您当然是对的,尽管奇怪的是,VS 都没有建议缺少使用引用,也没有 Telerik 的 JustCode。谢谢

标签: c# linq list dictionary where


【解决方案1】:

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

【讨论】:

  • 愚蠢的我,真的错过了。你当然是对的,但奇怪的是,VS 都没有建议缺少使用引用,也没有建议 Telerik 的 JustCode,这是我检查的第一件事。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-24
  • 1970-01-01
  • 2010-09-05
  • 1970-01-01
  • 2013-09-15
相关资源
最近更新 更多