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.)

Errata for Chapter 13: Minor changes to simplify code (C# 4)

P396, section 13.3.2: Typo describing variance

The callout in section 13.3.2 contains this text:

Any conversion using variance or covariance is a reference conversion

That appears to suggest that covariance is an alternative to variance... it should read:

Any conversion using covariance or contravariance is a reference conversion

P400, section 13.3.4: The button is missing in action!

The second paragraph below listing 13.15 contains this text:

The TInput parameter is only used in an input position, so it makes sense that you can use it contravariantly, using a Converter<object, string> as a Converter<Button, string>. In other words, if you can pass any object reference into the converter, you can certainly hand it a Button reference.

The listing never deals with buttons at all - only strings. The paragraph should read:

The TInput parameter is only used in an input position, so it makes sense that you can use it contravariantly, using a Converter<object, string> as a Converter<string, string>. In other words, if you can pass any object reference into the converter, you can certainly hand it a string reference.

(Alternatively, imagine the relevant changes in listing 13.15 to use buttons instead... there's nothing special about strings here.)

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.