C# 5.0 in a Nutshell

Errata for C# 5.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
PDF
Page 50
1st & 5th row

There's an extra "W" in the "Example" column of first row. A "-", (dash), is used instead of "~", (tilde) as Bitwise complement in 5th row.

Note from the Author or Editor:
Remove the stray 'w' after 'sizeof(int)' Change the dash to a tilde in the fifth row: ~ Bitwise complement ~x Yes It's a tilde in the source document; it must have got changed during conversion.

Bhavesh  Sep 09, 2012 
PDF
Page 99
code sample of reimplementing an interface in a subclass

public class RichTextBox : TextBox, IUndoable { public new void Undo() { Console.WriteLine ("RichTextBox.Undo"); } } should be: public class RichTextBox : TextBox, IUndoable { public new void Undo() { Console.WriteLine ("RichTextBox.Undo"); } } It is illegal to declare Undo method with new modifier. The Undo method in derived class doesn't hide any method in it base class, since the explictily implemented Undo method is tranparent to TextBox.

Note from the Author or Editor:
Change public new void Undo() { Console.WriteLine ("RichTextBox.Undo"); } to: public void Undo() { Console.WriteLine ("RichTextBox.Undo"); } (delete the word 'new')

DamnnnSure  Mar 07, 2013 
PDF
Page 159
above Overloading Equality and Comparison Operators

Shouldn't: Overloading an assignment operator automatically supports the corresponding compound assignment operator. Be: Overloading an operator automatically supports the corresponding compound assignment operator. I mean you can't overload assignment operator, right?

Note from the Author or Editor:
The sentence should read: Overloading an operator automatically overloads the corresponding compound assignment operator

Bhavesh  Oct 20, 2012 
Printed
Page 185
2nd example from the top

In the <include> example, the ending tag is </para> but should be </include>.

Philip Brown  Oct 31, 2012 
PDF
Page 416
Table showing results types for Average operator (8th paragraph)

The table shows (and the paragraph above it implies) that the result type of Average for a float selector is double, but I have verified that the output type of Average for a float selector is, in fact, float.

Note from the Author or Editor:
That sentence and table that follows should read as follows: Further, Average always returns either decimal, float or double, according to the following table: Selector type | Result type decimal | decimal float | float int, long, double | double (The table needs another row inserted for float, and the mention of float in the last row should be removed.)

Joseph Eddy  Aug 22, 2012 
PDF
Page 427
2nd paragraph (just after "Here’s the result of that last Console.WriteLine:")

The example output is missing a closing angle bracket (>).

Note from the Author or Editor:
The last line should end with a right angle bracket: </configuration>

Joseph Eddy  Aug 22, 2012 
PDF
Page 445
3rd paragraph (before "Prefixes" heading)

There is an erroneous "s" character after the quoted string "OReilly.Nutshell.CSharp" in the XML snippet (it's the second XML snippet on the page).

Note from the Author or Editor:
Delete the extraneous 's' character so it reads: <customer xmlns="OReilly.Nutshell.CSharp">

Joseph Eddy  Aug 23, 2012 
PDF
Page 461
bottom of the page

"ReadStartElement verifies that the current NodeType is StartElement" There is no such member as StartElement in the XmlNodeType enum. It should be just Element.

Note from the Author or Editor:
Correct: replace StartElement with Element.

KhanFusion  Feb 05, 2013 
PDF
Page 477
First paragraph

XLST written for XSLT

Joseph Eddy  Aug 24, 2012 
Printed
Page 478
.

XDocument doc = XDocument.Load (@"Customers.xml"); XElement e = e.XPathSelectElement ("customers/customer[firstname='Jim']"); // Here is mistake! I think it should be: XElement e = doc.XPathSelectElement ...

Note from the Author or Editor:
Correct: change 'e.XPathSelectElement...' to 'doc.XPathSelectElement...'

Anonymous  Feb 08, 2013 
PDF
Page 484
6th paragraph (near bottom of page)

XLST written for XSLT

Joseph Eddy  Aug 24, 2012 
Printed, PDF
Page 562
Bottom paragraph

In method Void UpdateMessage(string message), the line should read // Marshal the delegate to the UI thread: _uiSyncContext.Post(_ => txtMessage.Text = message, null); null is missing.

Note from the Author or Editor:
Correct: replace _uiSyncContext.Post (_ => txtMessage.Text = message); with _uiSyncContext.Post (_ => txtMessage.Text = message, null);

Anonymous  Apr 26, 2013 
PDF
Page 565
5th paragraph, starting "The Task class helps with all of these problems."

The word "avoid" should be 3rd person singular: "avoids". Context: "...and with a TaskCompletionSource, they can leverage a callback approach that avoid threads altogether while waiting on I/O-operations." Should read: "...that avoids threads altogether...".

S. Smith  Apr 17, 2013 
Printed
Page 568
4th paragraph

replace OperationCancelledOperation with OperationCancelledException

Note from the Author or Editor:
Change OperationCanceledOperation to OperationCanceledException Note also that there's one 'l' in canceled.

stefan Decuypere  Dec 20, 2012 
PDF
Page 572
2nd paragraph

The third sentence in the paragraph begins: "We can write this without a thread through use the Timer class" The word "use" should probably be removed, or possibly "through use" should be changed to "by using".

Note from the Author or Editor:
Sure: change to "by using"

Joseph Eddy  Aug 28, 2012 
PDF
Page 572
3rd paragraph (after first code snippet)

The word "any" is repeated: "...we can write its results without any blocking any thread:". The first "any" is a repetition typo to be removed.

Anonymous  Apr 17, 2013 
PDF
Page 581
1st paragraph

Third line from top reads: "...change-of-thread does not affect order execution and is of little consequence...". It should have "of" between "order" and "execution": "order of execution".

Anonymous  Apr 17, 2013 
PDF
Page 599
First code example

There is an undefined variable "someOperation" being referenced in the code example...I suspect that is meant to be a reference to the previously defined "task" variable.

Note from the Author or Editor:
Change 'someoperation' to 'task'

Joseph Eddy  Aug 28, 2012 
PDF
Page 629
Final paragraph

Before the parenthetical in the second sentence, "filesdata" should probably be changed to "data". At the end of the paragraph, "and the use asynchronous methods" should be something like "and using asynchronous methods".

Joseph Eddy  Aug 29, 2012 
PDF
Page 631
2nd paragraph

ZipFile class lives not in System.IO.Compression.dll, but in a System.IO.Compression.FileSystem.dll assembly. Also, the compression results from running examples in several previous sections should be updated. It seems that compressing algorithms were improved considerably in 4.5, so, for instance, thousand long empty array now compresses to mere 11 and not 113 bytes.

Note from the Author or Editor:
Replace System.IO.Compression.dll with System.IO.Compression.FileSystem.dll

KhanFusion  Jan 08, 2013 
PDF
Page 664
Concrete class listing under "Uploading data and HttpContent" header

"StreamContent" is listed twice, one of these should be "StringContent".

Note from the Author or Editor:
Change the second item from StreamContent to StringContent

Joseph Eddy  Aug 30, 2012 
Printed
Page 664
2nd paragraph

2nd paragraph says 'HttpResponseMessage has a CopyToAsync method for writing ... Actually it is the HttpContent class, not HttpResponseMessage, that has the CopyToAsync method being discussed.

Note from the Author or Editor:
Correct. Replace: HttpResponseMessage has a CopyToAsync method... with: HttpContent has a CopyToAsync method...

Philip Brown  Apr 21, 2013 
Printed
Page 859
Paragraph near the top

It seems MSDN refers to UAC as User 'Account' Control, not User 'Access' Control as shown near top of the page.

Philip Brown  May 11, 2013 
Printed
Page 963
2nd paragraph from the top

The 2nd paragraph starts with: 'This enables monitoring for the current domain'. According to MSDN write up on MonitoringIsEnabled = true, it means 'monitoring is enabled for all application domains for the current process'.

Note from the Author or Editor:
Change 'domain' to 'process'

Philip Brown  May 15, 2013 
Printed
Page 979
Middle paragraph

In the middle paragraph that starts with 'The fixed directive...', a sentence near the end says: 'Unlike with standard C# array, NumberArray is not...' It seems 'NumberArray' should be 'Numbers'.

Note from the Author or Editor:
Change "NumberArray" to "Numbers"

Philip Brown  May 16, 2013 
PDF
Page 985
Code sample at bottom of page

The third statement in the Main() function has: Workbook workBook = excel.Workbooks.Add(); Since in the "usings" above we alias Microsoft.Office.Interop.Excel as "Excel", this line should actually read: Excel.Workbook workBook = excel.Workbooks.Add(); In order to compile correctly.

Note from the Author or Editor:
Change: Workbook workBook = excel.Workbooks.Add(); to Excel.Workbook workBook = excel.Workbooks.Add(); And in the listing below, change Workbook workBook = excel.Workbooks.Add (missing); to Excel.Workbook workBook = excel.Workbooks.Add (missing);

Joseph Eddy  Sep 20, 2012 
Printed
Page 985
2 places around middle of page

On pages 985, 988, and possibly other pages, there are references to the type library importer tool 'tlimp.exe'. According to MSDN that should be 'tlbimp.exe' (missing the 'b')

Philip Brown  May 17, 2013 
Printed
Page 993
First code listing

Change the first line of the code listing from: Regex r = new Regex (@"sausages?"); to: Regex r = new Regex (@"sausages?" , RegexOptions.Compiled); And in the paragraph that follows, change : This is not just a syntactic convenience: under the covers, a RegEx instance uses lightweight code generation... to: RegexOptions.Compiled instructs the RegEx instance to use lightweight code generation...

Joseph Albahari
Joseph Albahari
O'Reilly Author 
Jun 12, 2013 
PDF
Page 994
Table 26-1

In the Table 26-1 "Regular expression" there's entry with following text: Enum value: Compiled Regular expressions code: c Decription: Forces compilation of regular expression to IL There's NO such inline option. It exists only when using constructor (http://msdn.microsoft.com/en-us/library/h5845fdz.aspx). Here are all legal options: http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx.

Note from the Author or Editor:
Delete the 'c' from the table (4th row, second column)

Eugene  Sep 30, 2012 
PDF
Page 995
Character Sets Expression/Meaning table

The table shows the regular expression \s as "same as" expression [\n\\r\t\f]...this is not true, since \s also will match a space character and [\n\r\t\f] will not...easily fixed by adding a space into that set: [\n\r\t\f ]

Note from the Author or Editor:
Replace [\n\r\t\f] with [\n\r\t\f\v ] (note space near end)

Joseph Eddy  Sep 20, 2012 
PDF
Page 995
Character Sets Expression/Meaning table

Actually, \s also matches the vertical tab (\v), so it should be something like: [\n\r\t\f\v ]

Note from the Author or Editor:
Replace [\n\r\t\f] with [\n\r\t\f\v ] (note the space near the end)

Joseph Eddy  Sep 20, 2012 
PDF
Page 1000
First code example

The output of the first example snippet has "In" as the second word, but it should be "in" (lowercase i)

Joseph Eddy  Sep 20, 2012 
Printed, PDF
Page 1007
Table 26-3 (Character Sets)

The table shows the regular expression \s as "same as" expression [\n\r\t\f]...this is not true, since \s also will match a space character as well as a vertical tab and [\n\r\t\f] will not...easily fixed by adding these characters into that set: [\n\r\t\f\v ]

Note from the Author or Editor:
Replace [\n\r\t\f] with [\n\r\t\f\v ]

Joseph Eddy  Sep 21, 2012 
PDF
Page 1043
4th Paragraph

Paragraph ends: "...often they will lay eggs directly on the ground, protected only spotted vegetation." This is grammatically incorrect, it should possibly read something like "protected only by spotted vegetation"...or something

Joseph Eddy  Sep 21, 2012