1.1. Introduction

Data domains are different from object domains. When we deal with objects like arrays and collections, we use iteration to retrieve their elements. If we're looking for a particular element based on its content rather than its index, we have to use a loop and process each element individually. For example, for an array of strings there is no built-in method to retrieve all elements whose length is equal to a particular value.

LINQ addresses this challenge by providing a uniform way to access data from any data source using familiar syntax. It lets us focus on working with data rather than on accessing it.

LINQ to Objects can be used with any class that implements the IEnumerable<T> interface. Let's look at how it works.

Get LINQ for Visual 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.