Getting Started

All the examples shown here are based on LINQ to Objects over in-memory data stored in collections. To make the LINQ functionality accessible, you need to make sure to have a reference to System.Core in your project (which is the case by default if you’re targeting .NET Framework 3.5 or later) and to have imported the System.Linq namespace in your code file. To check whether those requirements are met, write the following piece of code:

using System.Linq;...var n = new [] { 1, 2, 3 }.Count();

When doing so, you should see IntelliSense come up when typing the dot preceding the call to the Count method. Figure 19.10 illustrates what you should see if everything is okay. Notice the extension method icon ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.