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