Chapter 11. Composition using tuples
This chapter covers
Back in C# 3, LINQ revolutionized how we write code to handle collections of data. One of the ways it did that was to allow us to express many operations in terms of how we want to handle each individual item: how to transform an item from one representation to another, or how to filter items out of the result, or how to sort the collection based on a particular aspect of each item. For all that, LINQ didn’t give us many new tools for working with noncollections.
Anonymous types provide one kind of composition but with the huge restriction of being useful only within a block of code. You can’t declare that a method returns an anonymous type precisely because the return type can’t be named.