Errata: July 25, 2019

Thank you for purchasing C# in Depth, Fourth Edition . If you find an error, not listed below, please add it to LiveBook Errata thread. We'll update this list as necessary. Thank you!


Page 9

A closing bracket is missing the second example. The code should be:

throw new KeyNotFoundException(
    string.Format("No calendar system for ID {0} exists", id));

Page 35

The declaration for the LastOrDefault method is missing the type parameter T. The first line should be

public T LastOrDefault<T>(IEnumerable<T> source)

Page 338

The expansion of the != operator applied to tuples is incorrect. The expansion

Console.WriteLine(t1 != t2);

should be

Console.WriteLine(t1.Item1 != t2.Item1 ||
                  t1.Item2 != t2.Item2 ||
                  t1.Item3 != t2.Item3)

The difference is the use of the || operator; in the book I used the && operator.

Page 397, listing 13.13

The code in the Main method on page 397 is incorrect. Please replace it with the following:

static void Main()
{
    int x = 10;
    InParameter(x, () => x++);

    int y = 10;
    ValueParameter(y, () => y++);
}

Page 417

The word Mostly should be most as follows:

Most of the time you won’t even notice them, and you can refer back to this section if the compiler complains about code that you expect to be valid.