(You are currently looking at the first edition version of this page. This page is also available for the second
and third editions.)

Errata for Chapter 9: Lambda expressions and expression trees

P230: Incorrect use of "covariance"

On page 230 in the introduction to lambda expressions, I incorrectly talk about "parameter covariance". It should be "return type covariance" or "parameter contravariance" - both of which were added with C# 2.

P233, first text line: Extraneous comma

On page 233, in the first line of normal text, there's an extra comma in the quoted output. So where it says:

Listing 9.1 prints "5," just as we'd expect it to.

It should instead read:

Listing 9.1 prints "5" just as we'd expect it to.

The same issue comes up elsewhere in the text - we should probably use an automated "find" to check for all potential candidates.

P236: Briefer code in listing 9.4

The code in listing 9.4 can be abbreviated slightly. The lambda expression used to print the films list doesn't need braces. The code which appears like this:

Action<Film> print = film => { Console.WriteLine(film); };

can be changed to this:

Action<Film> print = film => Console.WriteLine(film);

This change has been made to the downloadable code.
See also this note for even more significant abbreviations.

P238: Briefer code in listing 9.5

The code in listing 9.5 can be abbreviated slightly. The three lambda expressions don't need to have braces. The section which currently reads like this: