Chapter 9. Lambda expressions and expression trees

This chapter covers

  • Lambda expression syntax

  • Conversions from lambdas to delegates

  • Expression tree framework classes

  • Conversions from lambdas to expression trees

  • Why expression trees matter

  • Changes to type inference

  • Changes to overload resolution

In chapter 5 we saw how C# 2 made delegates much easier to use due to implicit conversions of method groups, anonymous methods, and parameter covariance. This is enough to make event subscription significantly simpler and more readable, but delegates in C#2 are still too bulky to be used all the time: a page of code full of anonymous methods is quite painful to read, and you certainly wouldn’t want to start putting multiple anonymous methods in a single statement ...

Get C# in Depth 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.