Hello LINQ
Example. Hello LINQ
using System; using System.Linq; string[] greetings = {"hello world", "hello LINQ", "hello Apress"}; var items = from s in greetings where s.EndsWith("LINQ") select s; foreach (var item in items) Console.WriteLine(item); |
NOTE
The code in Listing 1-1 was added to a project created with the console application template in Visual Studio 2008. If one is not already present, you should add a using directive for the System.Linq namespace.
Running the previous code by pressing Ctrl+F5 outputs the following data to the console window:
hello LINQ
Get Pro LINQ: Language Integrated Query in C# 2008 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.