【问题标题】:Error message: 'OfType' is not a member of 'System.Text错误消息:“OfType”不是“System.Text”的成员
【发布时间】:2010-08-31 17:37:10
【问题描述】:

完整的错误是

Error 3 'OfType' is not a member of 'System.Text.RegularExpressions.MatchCollection'

在以下代码行中,(regex.Matches(input).OfType 中的花括号)

For Each group As Object In regex.Matches(input).OfType(Of Match)().Select(Function(c) c.Value.ToLowerInvariant()).Where(Function(c) Not keywords.Contains(c)).GroupBy(Function(c) c).OrderByDescending(Function(c) c.Count()).ThenBy(Function(c) c.Key)
  Console.WriteLine(group.Key)
Next

我不明白为什么这个在 VS2008 上可以正常工作,但在 VS2010 上却不行。

【问题讨论】:

    标签: .net visual-studio-2008 linq visual-studio-2010


    【解决方案1】:

    确定在VS2010下的代码中引用或Imports System.Linq

    【讨论】:

      【解决方案2】:

      OfTypeSystem.Linq.Enumerable 中的扩展方法,在System.Core 程序集中定义。 (System.Core.dll)

      您需要对 System.Core 程序集的引用,并且需要导入(VB 中的 Imports 和 C# 中的 usingSystem.Linq 命名空间。

      【讨论】:

        【解决方案3】:

        你需要导入System.Linq

        imports System.Linq
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-10-23
          • 1970-01-01
          • 1970-01-01
          • 2021-02-15
          • 1970-01-01
          • 2020-05-04
          • 1970-01-01
          相关资源
          最近更新 更多