代码之家  ›  专栏  ›  技术社区  ›  robob

LINQ在Mac OSX 104.4上不能与MyDeals/Muno的最后版本一起工作

  •  1
  • robob  · 技术社区  · 16 年前

    我正在尝试执行一个简单的测试代码:

    using System;
    using System.IO;
    using System.Linq;
    using System.Collections.Generic;
    
    namespace TestMono
    {
        public class TesterManager
        {
            public TesterManager ()
            {
                Console.WriteLine("Test");
                Path.GetTempPath();
    
                foreach (var i in new int[] { 1, 2, 3, 4, 5}.Where(n => n % 2 == 0))
            {
                Console.WriteLine(i);
            }
    
                List<string> ar= new List<string>();
                ar.Add("1"); ar.Add("2");
    
    
                var lb = ar.Where(n => n=="2");
            }
        }
    }
    

    编译代码时,我有两个错误:

    Esecuzione compilazione principale...
    /Library/Frameworks/Mono.framework/Versions/2.6.4/bin/gmcs /noconfig "/out:/Users/roberto/Projects/TestMono/TestMono/bin/Debug/TestMono.exe" /nologo /warn:4 /debug:+ /debug:full /optimize- /codepage:utf8 /platform:x86 "/define:DEBUG"  /t:exe "/Users/roberto/Projects/TestMono/TestMono/TesterManager.cs" "/Users/roberto/Projects/TestMono/TestMono/Main.cs" 
    Compilation failed: 2 error(s), 0 warnings
    
    /Users/roberto/Projects/TestMono/TestMono/TesterManager.cs(15,70): error CS1061: Type `int[]' does not contain a definition for `Where' and no extension method `Where' of type `int[]' could be found (are you missing a using directive or an assembly reference?)
    /Users/roberto/Projects/TestMono/TestMono/TesterManager.cs(24,37): error CS1061: Type `System.Collections.Generic.List<string>' does not contain a definition for `Where' and no extension method `Where' of type `System.Collections.Generic.List<string>' could be found (are you missing a using directive or an assembly reference?)
    

    我在项目属性中设置了mono/.net 3.5,并且我有mono和monobeloper的最新版本。我不明白那是怎么回事!

    2 回复  |  直到 16 年前
        1
  •  6
  •   holsee    16 年前

    为了访问“Stask.LINQ”命名空间,您可能需要添加“Stask.Cyr.DLL”的引用。

    This one had me scratching my head for a while, I was too used to Resharper bringing in my references.

        2
  •  2
  •   leppie    16 年前

    您是否添加了对Syr.Lyq.dLL的引用(或者它在莫诺河被称为什么)?

    (我可以发誓VS要求相同;P)