C# 3.0 in a Nutshell

Errata for C# 3.0 in a Nutshell

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page 9
Middle of page

static int InchesToFeet (int feet) {...} should read static int FeetToInches (int feet) {...}

Anonymous  Jul 30, 2008  Apr 01, 2009
Printed
Page 18
Figure 2-2

The figure does not match the code, either of code or figure should be change. The code reads p1.X =9 and p2.X=7 and remains unchanged, but in the figure we see that p1.X=7 and p2.X=9.

Note from the Author or Editor:
Figure 2-2 should be changed so that the numbers 7 and 9 are swapped around.

Morteza Manavi-Parast  Jun 21, 2009 
Printed
Page 86
near the top of the page

The page now ends with "for example:" followed by no example. Here are the 6 lines that should follow: class BaseClass { protected virtual void Foo() {} } class Subclass1 : BaseClass { protected override void Foo() {} } // OK class Subclass2 : BaseClass { public override void Foo() {} } // Error The compiler prevents any inconsistent use of access modifiers. For example, a subclass itself can be less accessible than a base class, but not more accessible: internal class A {} public class B : A {} // Error

Anonymous  Apr 07, 2009  Apr 01, 2009
Printed
Page 89
bottom of page

Note from the Author or Editor:
Note that the suggested correction isn't quite right: it should read: ...implements IUndoable.Undo explicitly. Also, on the last line of the page, it should read: IUndoable's Undo method.

Mark Owen  Jul 06, 2009 
Printed
Page 95
4th line

{95} 4th line, change Console.WriteLine (typeof(BorderSide), Enum.IsDefined (side)); //False to Console.WriteLine (Enum.IsDefined (typeof(BorderSide), side)); //False

Anonymous  Jul 06, 2008  Apr 01, 2009
Printed
Page 98
Section: "Generic Method"

In the example: static void Swap<T> (ref T a, ref T b) { T temp = b; //SHOULD BE EITHER T temp = a; a = b; // OR b = a; b = temp; }

Note from the Author or Editor:
Method should be: static void Swap<T> (ref T a, ref T b) { T temp = a; a = b; b = temp; }

Daniel  Aug 28, 2009 
Printed
Page 131
3rd code example (starts with "var enumerator")

I believe this code example should include at the end the line: enumerator.Dispose(); If this code is (as it states) intended to be functionally the same as a foreach statement shown above.

Note from the Author or Editor:
This has been fixed in the 4th edition.

HoganLong  Nov 02, 2009 
Printed
Page 171
table 6-1

[3/08 printing] in the 2nd column of the IsWhiteSpace row and the IsControl row, control characters using incorrect syntax: "/n" should be "\n", etc

Note from the Author or Editor:
In the 2nd column of the IsWhiteSpace and IsControl rows, replace all forward slashes (/) with backslashes (\)

Anonymous  Aug 14, 2008  Apr 01, 2009
Printed
Page 266
2nd line

if (Zoo != null) Zoo.NotifyNameChange(this, value); should bee: if (Zoo != null) Zoo.Animals.NotifyNameChange(this, value);

Anonymous  Jun 18, 2008  Apr 01, 2009
Printed
Page 283
Figure 8-2 and inside back cover

There's an error in Figure 8-2 on page 283 - which is also reproduced on the back cover. There's an extra line betweeen the select and group-clause boxes which shouldn't be present. Here's how it should look: http://www.albahari.com/nutshell/linqsyntax.aspx

Anonymous  Apr 07, 2009  Apr 01, 2009
Printed
Page 314
1/4 way down from top of page

In code sample 1/4 down the page, cust.Purchases.Remove(p2) should read: cust.Purchases.Add(p2)

Note from the Author or Editor:
A correction was submitted for the third printing.

Anonymous  Jul 11, 2008  Aug 01, 2008
Printed
Page 314
1/2 way down page

Need to change "100" to "1". Sentence: "In this example, LINQ to SQL automatically writes 100 into the CustomerID column... " Should read: "In this example, LINQ to SQL automatically writes 1 into the CustomerID column... "

Anonymous  Jul 11, 2008  Aug 01, 2008
Printed
Page 315
First code sample near top of page

The line: Customer cust = dataContext.Customers.Single(c => c.ID == 1); is superfluous. It does not need to be there and should be deleted.

Note from the Author or Editor:
Confirmed: delete first line in that code listing (top of page 315) as described.

Anonymous  Jul 11, 2008  Aug 01, 2008
Printed
Page 324
Filtering Method Table, Middle of page

The descriptions for the methods 'TakeWhile' and 'SkipWhile' both state [Emits|Ignores] elements from the input sequence until the predicate is true This is incorrect, they operate while the predicate is true, and operate until the predicate is false. From MSDN on TakeWhile: http://msdn.microsoft.com/en-us/library/bb534804.aspx "Returns elements from a sequence as long as a specified condition is true." The examples on page 327 also make the operation clear. The problem is that the operations continue WHILE the predicate is true, rather than UNTIL. To use until, you would have to state they continue until false, which is awkward. They should be reworded, as their function name suggests, to say they perform their action WHILE the predicate is true.

Note from the Author or Editor:
Table, half way down page 324: - In the middle column ("Description") of TakeWhile, change "until" to "while" so that it reads "Emits elements from the input sequence while the predicate is true" - In the middle column ("Description") of SkipWhile, change "until" to "while" so that it reads "Ignores elements from the input sequence while the predicate is true, and then emits the rest" Similarly, half way down page 327, change "until" to "while" in the first and second sentences under section "TakeWhile and "SkipWhile".

Anonymous  Mar 13, 2009  Apr 01, 2009
PDF
Page 405
Output for the example

writer.WriteStartElement (

Note from the Author or Editor:
Page 406, first code listing, third line. Change "firstname" to "lastname", so that it reads: writer.WriteStartElement ("o", "customer", "http://oreilly.com"); writer.WriteElementString ("o", "firstname", "http://oreilly.com", "Jim"); writer.WriteElementString ("o", "lastname", "http://oreilly.com", "Bo"); writer.WriteEndElement();

NARESH GUDURI  Jul 02, 2009 
Printed
Page 436
top of page

In the last sentence of note at the top of the page, "setion" should be "section".

Anonymous  Apr 09, 2009 
Printed
Page 442
Second bullet under the heading, "Named pipes"

In the sentence, "The client instantiates a NamedClientStream and then calls Connect (with an optional timeout)", "NamedClientStream" should say "NamedPipeClientStream".

Fred Sawtelle  May 12, 2009 
Printed
Page 443
Last word of 1st paragraph.

"in other words, reads until IsMessageComplete is false:" should be "in other words, reads until IsMessageComplete is true:". In the example given, the do-while loop exits when (!s.IsMessageComplete ) is false. VS' Object Browser tells me: public bool IsMessageComplete {get;} IsMessageComplete Returns: true if there are no more characters to read in the message; otherwise, false.

Paul Mackintosh  Nov 24, 2009 
Printed
Page 564
9th line

Page 564, 9th line Change: Console.WriteLine(t); To: Console.WriteLine(t.FullName);

Anonymous  Jul 24, 2008  Apr 01, 2009
Printed
Page 564
2nd line from the bottom

the output of Console.WriteLine(t.FullName) should be: // System.Environment+SpecialFolder instead of: // System.Environment+StringBuilder

Anonymous  Oct 08, 2008  Apr 01, 2009
Printed
Page 569
Middle of page

In the sentence "...whereas RefectedType returns the subtype." RefectedType should read ReflectedType

Anonymous  May 31, 2009 
Printed
Page 587
Passing Arguments to a Dynamic Method section, 4th line

Page 587, Passing Arguments to a Dynamic Method section, 4th line Change: when calling DefineMethod. to: when calling DynamicMethod constructor.

Note from the Author or Editor:
Change: when calling DefineMethod. to: when calling DynamicMethod's constructor.

Anonymous   
Printed
Page 587
Passing Arguments to a Dynamic Method section, 4th line

Page 587, Passing Arguments to a Dynamic Method section, 4th line Change: when calling DefineMethod. to: when calling DynamicMethod constructor.

Note from the Author or Editor:
Change: ...when calling DefineMethod. to: ...when constructing the DynamicMethod.

Anonymous  Jul 26, 2008  Apr 01, 2009
Printed
Page 600
Attaching Attributes section, 5th-to-last line

Page 600, Attaching Attributes section, 5th-to-last line Change: new object[] { "FirstName", 3 } // Property values To: new object[] { "http://test/", 3 } // Property values

Anonymous   
Printed
Page 600
Attaching Attributes section, 5th-to-last line

Page 600, Attaching Attributes section, 5th-to-last line Change: new object[] { "FirstName", 3 } // Property values To: new object[] { "http://test/", 3 } // Property values

Note from the Author or Editor:
Good spot.

Anonymous  Jul 26, 2008  Apr 01, 2009
Printed
Page 601
Second code snippet, 2nd-to-last line

Page 601, second code snippet, 2nd-to-last line Change: gen.Emit(OpCodes.Ldarg_1); To: gen.Emit(OpCodes.Ldarg_0);

Anonymous   
Printed
Page 601
Second code snippet, 2nd-to-last line

Page 601, second code snippet, 2nd-to-last line Change: gen.Emit(OpCodes.Ldarg_1); To: gen.Emit(OpCodes.Ldarg_0);

Note from the Author or Editor:
The line to change is about 2/3 way down the page. It should read: gen.Emit (OpCodes.Ldarg_0); And to whoever reported this, well-spotted!

Anonymous  Jul 26, 2008  Apr 01, 2009
Printed
Page 651
The first sentence of the last paragraph

Instead of "The final argument to BeginInvoke is a user state object that populates the AsyncResult property of IAsyncResult." it should be "The final argument to BeginInvoke is a user state object that populates the AsyncState property of IAsyncResult.". Please note "AsyncState" instead of "AsyncResult".

Alexey Shestialtynov  Dec 30, 2008  Apr 01, 2009
Printed
Page 710
First paragraph

A method is incorrectly referred to as "AppDomain.UnloadDomain". It should read "AppDomain.Unload".

Eric Bank  Jun 14, 2009