How do I use Linq in MonoDevelop 2.0 on OS X?

后端 未结 6 906
终归单人心
终归单人心 2021-01-04 07:55

I installed MonoDevelop 2.0 on my Mac.

I created a new Console Application.

\"Hello World\" program runs fine.

But I can\'t use Linq.

u

6条回答
  •  心在旅途
    2021-01-04 08:33

    I'm running Monodevelop 2.0 and Mono 2.0 on Ubuntu 9.04 and lambda's and Linq work fine.

    Contrary to what Thomas Levesque says, System.Core does exist in Mono. Extension methods, lambda's et al are all supported.

    You need to use using System.Linq.

    public static void Example1()    
    {
    
        List people = new List() 
        { 
            "Granville", "John", "Rachel", "Betty", 
            "Chandler", "Ross", "Monica" 
        };
    
        IEnumerable query = from p in people where p.Length > 5 
        orderby p select p;
    
        foreach (string person in query) 
        {
            Console.WriteLine(person);
        }
    }
    

提交回复
热议问题