O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required