C# in Depth

Cover of C# in Depth
Order now (3rd edition)

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

All Errata

P22/23, listing 1.21: Incorrect formatting

The formatting in listing 1.21 is fine until the last line of page 22 - but that closing brace should be outdented, and then on page 23 the productCheckButton.Enabled = true; line should be indented.

The code will already execute perfectly happily - it's just not pleasant to look at.

P23, section 1.6: Incorrect listing reference

Directly after listing 1.21, I state that "The full method is a little longer than the one shown in listing 1.22," where of course I meant listing 1.21 instead - listing 1.22 doesn't exist.

P33, figure 2.2: Incorrect figure included (again)

This problem has been fixed. Please download the latest version of the ebook if you see this issue in your version.

Just like in the second edition, figure 2.2 in the ebook is the wrong figure.

Figure 13.1 has accidentally been included again as figure 2.2. The real figure 2.2 should look like this:

Figure 2.2 - delegate combination

P53, listing 2.6: Just how old are you, Jon?

Eagle-eyed readers may have noticed that in listing 2.6, I claim to be 31 years old, whereas in later listings throughout the book I'm 36 or 37. Sad to say, it's the latter age which was correct as the third edition went to print - I was born in June 1976. These days I can barely remember what it was like to be 31.

In fact, this was a problem in the second edition as well. It seems that chapter 2 is a chapter of eternal youth, basically. All the code works - it's just the data is inconsistent between listings.

This actually raises an interesting point about storing time-sensitive data: always try to store a fixed reference point rather than a dynamic value. If I'd had a DateOfBirth property instead of an Age property, nothing would have needed updating between editions at all. That's what I'd have done for real code, but Age = 37 is a good deal shorter than DateOfBirth = new DateTime(1976, 6, 19) even leaving aside the thorny issue of how suitable DateTime is for storing a date.

P98, listing 3.14: Duplicated annotation

The second annotation in listing 3.14 is "Uses implicit conversions to call comparer" (the same as the third annotation). It should actually be "Remembers original comparer".

P119, section 4.3.3: Space missing between true and false

The list of overloadable operators includes truefalse. This should be true false (i.e. two different operators).

P222, listing 8.3: Extra comma in listing

Listing 8.3 currently includes this:

new Person("Alice"),
{
    Age = 9,
    Home = { Town = "Twyford", Country = "UK" }
}

The comma after the constructor call needs to be removed, like this:

new Person("Alice")
{
    Age = 9,
    Home = { Town = "Twyford", Country = "UK" }
}

P346, section 12.3.1: XText creation

When describing XText, the book states:

XText is rarely instantiated directly in user code; instead, when a string is used as the content of an element or document, that’s converted into an XText instance.

That's somewhat misleading, as it ignores all the other conversions which implicitly create XText nodes. Basically, any time you create text within an element, it will be a form of XText. For example, consider this code:

new XElement("x", 0)

This creates this XML:

<x>0</x>

The 0 has been specified as an integer literal, but in the object tree there's still an XText object, as you can tell by calling element.Nodes().First().GetType().

P406, section 13.4.1: Incorrect method call

In the listing on page 406 - the second listing in section 13.4.1 - I mistakenly have a call to Monitor.Release in the finally block. That method doesn't actually exist; in should be a call to Monitor.Exit, just as it was in the previous listing.

P473, section 15.3.2: Typo around Task<TResult>

The published text has (just after the list at the start of the section):

The difference between the two is essentially that Task<TResult> represents an operation that returns a value of type T [...]

The T should be TResult:

The difference between the two is essentially that Task<TResult> represents an operation that returns a value of type TResult [...]

P503, section 15.5.6: Last line of listing should be bold

The last line of the listing on page 502/503 has a comment of // Bold at the end. That was an instruction to make the line bold, rather than a normal C# comment, but unfortunately it wasn't picked up during layout.

P505, section 15.6.1: Note to production still present

In section 15.6.1, there's a note I left to the Manning production department:

// NOTE TO PRODUCTION: Please consult with Jon on formatting. Do not abbreviate!

Obviously this shouldn't have appeared in the final copy. Sorry about that!

P511, section 15.6.2: Missing space

On page 511, just after listing 15.13, there's a sentence missing a space:

There are two slight issues with listing15.13:

This should of course be:

There are two slight issues with listing 15.13:

P522, listing 16.3: Incorrect indentation

In listing 16.3, the body of the attribute constructor (Member = member;) should be indented.

P522, under listing 16.4: Incorrect listing reference

Just under listing 16.4, I accidentally refer to listing 16.3... while giving the output of listing 16.4. So this:

Listing 16.3 just prints Called by: Unknown as if the output weren't present.

should be:

Listing 16.4 just prints Called by: Unknown as if the output weren't present.