I can't make System.Linq (aka LINQ to Objects) work. I am running MonoDevelop 2.2.1 in Ubuntu 10 Lucid Lynx with Mono 2.4.4.
They advertise in their site that they implemented LINQ, but I can't even find Enumerable.Range
or ToArray()
. What's wrong?
LINQ in C# is used to work with data access from sources such as objects, data sets, SQL Server, and XML. LINQ stands for Language Integrated Query. LINQ is a data querying API with SQL like query syntaxes. LINQ provides functions to query cached data from all kinds of data sources.
Readable code: LINQ makes the code more readable so other developers can easily understand and maintain it. Standardized way of querying multiple data sources: The same LINQ syntax can be used to query multiple data sources.
I guess what you would need to do is:
after that your code should compile and execute
hope this helps, regards
Are you using the gmcs
compiler? mcs
does not seem to compile code containing Linq.
$ cat a.cs using System; using System.Linq; class Test { static void Main() { foreach (var i in new int[] { 1, 2, 3, 4, 5}.Where(n => n % 2 == 0)) { Console.WriteLine(i); } } } $ gmcs a.cs $ ./a.exe 2 4
To compile with gmcs
, perform the following instructions as described by the MonoDevelop FAQ:
Can I compile my project with gmcs?
Yes. Right click on your project, select 'Options'->'Runtime' and select '2.0' from the drop-down list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With