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

All Errata

Px, table of contents: The mysterious position of part 2

The table of contents claims that part 2 starts on page 155, but that the first chapter within it starts on page 57.

This is a typo - part 2 does of course start on page 55 instead.

Pxxiv, acknowledgements: Oops - sorry Marc!

Marc Gravell's name has been mis-spelled in the acknowledgements as "Marc Gravel". Sincere apologies, Marc - no offence intended!

This will hopefully be fixed in the next version of the ebook, but is incorrect in the printed version.

P12, Listing 1.11: Lack of space between type and variable name

Listing 1.11 contains this line of code:

List<Product>matches = products.FindAll(test);

There should be a space between the type name and the variable name:

List<Product> matches = products.FindAll(test);

P6, listing 1.2: Italic type name and spacing

The GetSampleProducts declaration in listing 1.2 has the return type in italics instead of in bold, and it has an extra space after it:

public static List<Product>  GetSampleProducts()

It should actually be in bold, with just one space:

public static List<Product> GetSampleProducts()

P33, figure 2.2: Incorrect figure included

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

This is not an issue in the printed book, fortunately - and will be fixed in a future version of the ebook, to be distributed soon.

P35, section 2.1.3: Incorrect link

The short link used in the second paragraph of page 35 goes to the wrong web page - one about parameter passing. Unfortunately the same link is used on page 47, so I can't just change the target of the short link.

The link should reference my page on events and delegates.

P37, footnote 8: The bizarrely emphasized "u"

For some reason, footnote 8 on page 37 contains this phrase, with this formatting:

but this doesn't affect C# 1's status of being statically typed

Obviously the "u" shouldn't be italicized here.

P51, section 2.4.1: "principle" vs "principal" failure

The final sentence of page 51 reads:

Indeed, generics form one of the principle enhancements to the type system, which we'll look at next.

Oops - this should be principal instead:

Indeed, generics form one of the principal enhancements to the type system, which we'll look at next.

P94, section 3.5.1: IShape, not Shape

In section 3.5.1, page 94, just above the bulleted list, it states:

We can't convert from an IEnumerable<Circle> to an IEnumerable<Shape>.

However, there's no such type as Shape in our situation - we have an interface instead. So the sentence should actually say:

We can't convert from an IEnumerable<Circle> to an IEnumerable<IShape>.

P96, sample declarations: Incorrect declaration for generic AreaComparer

On page 96, I offer a workaround to the lack of variance in the AreaComparer example. I suggest that we can make the class generic:

class AreaComparer<T> : IComparer<IShape> where T : IShape

class AreaComparer : AreaComparer<IShape>

This wouldn't actually help - we need to implement IComparer<T> in order to use it to sort a List<Circle> or something similar. It can be fixed with just a small change though:

class AreaComparer<T> : IComparer<T> where T : IShape

class AreaComparer : AreaComparer<IShape>

P110, section 4.2.2: Missing space in section title

The section heading for 4.2.2 is missing a space between "Nullable<T>" and "and". It should of course be: "Boxing Nullable<T> and unboxing".

P110, section 4.2.2: Incorrect arrow in listing

The first annotation in listing 4.2 - "Boxes nullable with value" - has an arrow pointing at the first line of code in the listing. It should actually point at the second line of code (object boxed = nullable;) as that's the line where boxing occurs.

P117, section 4.3.3: Incorrect section reference

The final bullet on page 117 refers to section 4.3.6 for the behaviour of & and |, but these are actually described in section 4.3.4.

P152, section 5.5.6: inner/inside, outer/outside mistakes

The bottom paragraph of page 152 refers to inner and outer, but the code they're referring to actually uses variables called inside and outside.

There's nothing clever going on here - it was just a typo.

P164, section 6.2.2: Incorrect section reference

In the penultimate paragraph of section 6.2.2, I refer to section 6.3.7. This doesn't exist - the reference should actually be to section 6.3.3.

P165, section 6.2.3: Incorrect section reference

In the penultimate line of section 6.2.3, I refer to section 6.3.6. This doesn't exist - the reference should actually be to section 6.3.2.

P182, section 7.1.1: Incorrect bullet point reference

The second paragraph on page 182 starts:

Only (1) specifies any type constraints, and only (3) specifies a base class. If (1) had specified a base class, it would have to be EventArgs, and if (4) had specified any type constraints they'd have to be exactly as in (1).

The (4) there should be a (3).

P232, listing 9.3: Missing semi-colon

The first line of listing 9.3 is this:

Func<stringint> returnLength

That's missing a semi-colon. It should actually be:

Func<stringint> returnLength;

P245, section 9.3.5: Typo in sample

The sample code on page 245 is incorrect. It should be this:

T runningTotal = initialValue;
foreach (T item in values)
{
   runningTotal = Operator.Add(runningTotal, item);
}

Note the second argument, which should be item, not values.

P254, section 9.5: Typo on last line

On the last line of page 254, "resticted" should be "restricted".

P304, section 11.5.1: Incorrect method signature for Join

The method signature for Join is incorrect. The fourth parameter should use TInner rather than Inner, giving a signature like this:

static IEnumerable<TResult> Join<TOuter,TInner,TKey,TResult>(
    this IEnumerable<TOuter> outer,
    IEnumerable<TInner> inner,
    Func<TOuter,TKey> outerKeySelector,
    Func<TInner,TKey> innerKeySelector,
    Func<TOuter,TInner,TResult> resultSelector
)

P305, section 11.5.1: Missing "a"

The top few lines of page 305 contain:

and creates an anonymous type and simple mapping to use for the resultSelector parameter

This would perhaps be better with an extra "a":

and creates an anonymous type and a simple mapping to use for the resultSelector parameter

P310, section 11.5.3: Typo in SelectMany signature

In the signature of SelectMany, I refer to a mysterious generic IEnumerable type with two arguments for some reason... the correct signature should be:

static IEnumerable<TResult> SelectMany<TSource,TCollection,TResult>(
    this IEnumerable<TSource> source,
    Func<TSource,IEnumerable<TCollection>> collectionSelector,
    Func<TSource,TCollection,TResult> resultSelector
)

P317, first paragraph: Incorrect section reference

In the first paragraph on page 317, I refer to a defect-tracking query in section 10.3.4. However, the query actually occurs in section 10.3.6.

P344, section 12.3.4: Incorrect section reference

A few lines up from the bottom of P344, I refer to "the axis methods mentioned in section 12.4.3". They're actually discussed in section 12.3.3 instead.

P360, section 12.6.2: Incorrect reference

The third line of page 360 refers to section 10.3.7 and an implementation of Where. This reference should be to section 10.3.3 (page 269).

P367, section 13.1.1: Incorrect annotation reference

Just after listing 13.1, I have the following text:

The first call [2] explicitly specifies all the arguments; the remaining calls ([2] and [4]) omit one or two arguments respectively

The second occurrence of [2] should actually be [3]:

The first call [2] explicitly specifies all the arguments; the remaining calls ([3] and [4]) omit one or two arguments respectively

P375, section 13.1.2: Clarifying the explanation of listing 13.4

After listing 13.4, the explanation starts with:

In both cases, the parameters in the Dump method are still 1, 2, and 3, in that order

This would perhaps be clearer as:

In both cases, the parameters x, y and z in the Dump method still have the values 1, 2, and 3 respectively.

P408, section 14.3: Typo in introductory section

In the introduction to section 14.3, one paragraph ends with:

it'll be an interesting area to keep can eye on.

That should of course be:

it'll be an interesting area to keep an eye on.

P421, section 14.4: Typo in section 14.4

Section 14.4 contains the following text:

Despite the warning of the previous paragraph, I’m won’t go into huge amounts of detail about the inner workings of dynamic typing.

The "I'm won't go" should be "I won't go":

Despite the warning of the previous paragraph, I won’t go into huge amounts of detail about the inner workings of dynamic typing.

P438, section 14.5.1: Incorrect closing XML tag

The XML on P438 is invalid - the final line should read </books> instead of </book>.

P481, listing 15.17: Incorrect Ensures call

The postcondition in listing 15.17 is incorrect. Instead of this:

Contract.Ensures(text != null);

It should be:

Contract.Ensures(Contract.Result<string>() != null);

The generated XML changes in exactly the same way:

<ensures>Contract.Result&lt;string&gt;() != null</ensures>

P493, section 16.3: Small typo (ulta to ultra)

On P493, the final paragraph of section 16.3 includes:

ranging from ulta-fast connections in data centers

This should, of course, be:

ranging from ultra-fast connections in data centers

P514, section B.2.5: Typo on requirements for ReadOnlyObservableCollection

On page 514, I claim:

A ReadOnlyObservableCollection<T> instance can only be constructed with an Observable<T> backing list.

Whoops. As per the constructor documentation, I meant it can only be constructed with an ObservableCollection<T>.