Case Study: Delegates Used in LINQ to Objects
Although we defer a more thorough discussion about LINQ until Chapter 19, I think it’s worthwhile to spend a bit of time illustrating the use of delegates in the context of LINQ. One of the built-in “providers” for Language Integrated Query allows for querying over in-memory data sequences and is known as LINQ to Objects.
Various query operators are implemented as methods that take in an IEnumerable<T>
sequence as one of their inputs, typically returning a derived sequence as a result. Such operators form the building blocks to build more complex queries from. In other words, those query operators allow for rich composition, in large part because of their functionally inspired nature. Let’s illustrate ...
Get C# 5.0 Unleashed 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.