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

北城余情 提交于 2019-11-30 01:53:09

问题


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.

using System. doesn't show Linq option.

What should I do?


回答1:


You may need to right-click on your project in the solution view, do Options, Build, General, and set your Target Runtime to Mono / .Net 3.5 or bigger.

Then you can right-click references, do Edit References, and add a reference to System.Core to your project.




回答2:


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<string> people = new List<string>() 
    { 
        "Granville", "John", "Rachel", "Betty", 
        "Chandler", "Ross", "Monica" 
    };

    IEnumerable<string> query = from p in people where p.Length > 5 
    orderby p select p;

    foreach (string person in query) 
    {
        Console.WriteLine(person);
    }
}



回答3:


The Latest version of Mono Develop does support linq. On the project you must select 3.5 under Build/General/RuntimeVersion. After that you can add the System.Core reference.




回答4:


Is your Console Application referencing the System.Core.dll? You need to reference it in order to use System.Linq.




回答5:


Check if your project references on System.Xml.Linq library too




回答6:


Not sure LINQ is fully implemented within the current release http://www.mono-project.com/Roadmap



来源:https://stackoverflow.com/questions/871230/how-do-i-use-linq-in-monodevelop-2-0-on-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!