Errata

C# 6.0 in a Nutshell

Errata for C# 6.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 15-16
list of reserved keywords and list of contextual keywords

The keyword 'in' appears in both the reserved keyword list and the contextual keyword list.

Note from the Author or Editor:
The 'in' keyword should appear only in the list of reserved keywords. Remove the 'in' keyword from the list of contextual keywords.

Anonymous  Dec 08, 2015  Dec 18, 2015
Printed
Page 15
List after second paragraph.

Item "longnamespace" should be two different items "long" and "namespace".

Steve Beaudoin  Feb 20, 2016  Apr 01, 2016
PDF
Page 25
Paragraph under the heading: Bool Conversions

The Paragraph: "No conversion can be made from the bool type to numeric types or vice versa."

I do not believe that this is the intent, I believe that the intent is "No casting conversion can be made from..."

Thank you for your attention.
--Avi

Avi Farah  Jul 17, 2015  Nov 03, 2015
Printed
Page 29
Specialized Integral Operations -> Integral Division -> first paragraph

Keywords and identifiers in normal text are divided wherever the line ends - in this case 'DivideByZeroException' is separated into 'Divid' at the end of the second line of the paragraph and 'eByZeroException' at the beginning of the third line.

That's just one of numerous examples. My guess is, that the corresponding style description is broken (at least for print). These expressions should not be separatable _at_all_ in normal text except at blanks!

To call it annoying is an understatement, because when happening at the right position I can only guess if it is meant to be two words or one expression instead ...

Note from the Author or Editor:
We should avoid breaking over literal-styled words where possible.

Klaus Jonke  Jan 19, 2016  Apr 01, 2016
PDF
Page 36
2nd piece of code from bottom

The code:
string a2 = @ "\\server\fileshare\helloworld.cs";

Should be:
string a2 = @"\\server\fileshare\helloworld.cs";

Note from the Author or Editor:
Remove the space between the @ sign and the " symbol.

Bhavesh  Oct 15, 2016  Apr 14, 2017
Printed
Page 37
Second paragraph in String Interpolation section

You discuss how to format an interpolated string in this section, but not how to pad it. However, you appear to demonstrate this feature much later (pg. 1050) without any discussion:
Console.WriteLine($"{token.Kind(),-30} {token.Text}");

Note from the Author or Editor:
The cross-reference is incorrect. Change

(format strings are described in "Formatting and Parsing” in Chapter 6)

to:

(format strings are described in "“String.Format and composite format strings” in Chapter 6)

Jason  Oct 22, 2016  Apr 14, 2017
PDF
Page 49
1st aside (caution or warning)

The text:
just as though the parameter were mandatory.

Should be:
just as though the parameter was mandatory.

Bhavesh  Oct 15, 2016  Apr 14, 2017
PDF
Page 49
3rd paragraph

There is typo in second word "nameSpace"

"The namepace keyword defines a namespace"

AntonS  Aug 22, 2015  Nov 03, 2015
Printed
Page 56
line 25

string s = (sb == null ? "nothing" : sb.ToString()); // the original line
if (s == null) s = "nothing"; // this is missing
// the original line is not strictly equivalent to the code line 23 because
// when sb.ToString() returns null, s in line 23 is "nothing", in 25 is null

Note from the Author or Editor:
Delete the following text:

The last line is equivalent to:
string s = (sb == null ? "nothing" : sb.ToString());

Wenbo Zhao  Feb 10, 2017  Apr 14, 2017
PDF
Page 75
2nd paragraph

The text:
A method’s signature comprises its name and parameter types

Should also include order of parameters.

Note from the Author or Editor:
Change " parameter types" to " parameter types in order"

Bhavesh  Oct 20, 2016  Apr 14, 2017
PDF
Page 101
Structs section, last para

this incurs a useful savings when

should be:
this incurs useful savings when

or:
this incurs a useful saving when

Note from the Author or Editor:
Change to "this incurs a useful saving when... "

Bhavesh  Oct 30, 2016  Apr 14, 2017
Printed
Page 115
Example under 3rd paragraph

In the example that shows the effective substitution for Stack<int> the line:

int[] data;

should read:

int[] data = new int[100] ;

Andrew Charlton  May 11, 2016  Aug 12, 2016
PDF
Page 187
Paragraph under the heading Pointer Basics

Should the sixth word in "For every value type or pointer type V, there is a corresponding pointer type V*." be reference instead of pointer?

Note from the Author or Editor:
Correct. The sentence should read: "For every value type or reference type V...

Anonymous  May 05, 2016  Aug 12, 2016
PDF
Page 196
3rd paragraph from bottom

void Z(char[ ] 1, float[,] p2) {...}

should be

void Z(char[ ] a1, float[,] p2) {...}

Bhavesh  Apr 08, 2017  Apr 14, 2017
PDF
Page 219
last para

CompareTo instance method or
the static Compare and CompareOrdinal methods: these return a positive or negative
number—or zero—depending on whether the first value comes before, after, or
alongside the second.

This is wrong because following two pages later is right.

All of the order-comparison methods return a positive number, a negative number,
or zero, depending on whether the first value comes after, before, or alongside the
second value:

Bhavesh  Apr 24, 2017 
Printed
Page 233
Paragraph above the Warning box

Within the section "Formatting and parsing" on page 233 there is the text 'ToString is overloaded to accept a format string and provider...
We describe this in "Formatting and parsing on page 233." '
That should read:
'We describe this in "Formatting and parsing" on page 240"

Andrew Charlton  May 17, 2016  Aug 12, 2016
Printed
Page 570
General note under "Locking and Thread Safety"

The text says 'For a full discussion, see ... and "Locking and Thread Safety' on page 570 in Chapter 22.' The page reference should be 912.

Andrew Charlton  Jun 01, 2016  Aug 12, 2016
Printed
Page 585
1st paragraph of the notice.

At the end of the paragraph, "we wouldn't care if turns out..." should probably be "we wouldn't care if it turns out...".

sbeaudoin  Mar 02, 2016  Apr 01, 2016
Printed
Page 586
Last paragraph.

In the last phrase, "on page 585 in chapter 23.". Chapter 23 starts at page 945.

Note from the Author or Editor:
should read: "page 972 in Chapter 23."

sbeaudoin  Mar 02, 2016  Apr 01, 2016
PDF
Page 591
First paragraph

The expression, "course-grained" should be "coarse-grained".

This error occurs more than once - e.g. on page 592, at the end of the paragraph starting, "Now we have a call graph", twice in the final paragraph of page 599 (although the heading to that section has the correct spelling), and in the final paragraph on page 620.

Gareth Erskine-Jones  Jan 13, 2017  Apr 14, 2017
PDF
Page 593
method DisplayPrimeCountsFrom(int i)...

void DisplayPrimeCountsFrom (int i)
{
var awaiter = GetPrimesCountAsync (i*1000000 + 2, 1000000).GetAwaiter();
awaiter.OnCompleted (() =>
{
Console.WriteLine (awaiter.GetResult() + " primes between...");
if (i++ < 10) DisplayPrimeCountsFrom (i);
else Console.WriteLine ("Done");
});
}

Here within awaiter.OnCompleted(()=>...), if(i++ <10) ... should be if(++i <10) instead. I am sure the author knows the difference between pre-increment and post-increment and it does make a difference here if the intent is to loop 10 times not 11 times.

stt106  Feb 15, 2017  Apr 14, 2017
PDF
Page 596
second to last paragraph

Upon first executing GetPrimesCount..., it should be GetPrimesCountAsync.

stt106  Feb 16, 2017  Apr 14, 2017
Printed
Page 772
First sentence in section ".resource Files"

The sentence "The Framwork also lets you add .resource files are... does not quite make sense. Possibly this should read "...add .resource files, which are..."

Andrew Charlton  Nov 11, 2016  Apr 14, 2017
Printed
Page 861
end of first code block

ScriptEngine does not have a GetVariable method. The GetVariable method is defined on ScriptScope, and requires a single string argument specifying the name of the variable you wish to retrieve.

Note from the Author or Editor:
Yes, this needs to be updated to work with the latest version of IronPython.

The last line of the first code listing on page 861 should read:

Console.WriteLine (scope.GetVariable ("result")); // 6

instead of

Console.WriteLine (engine.GetVariable (scope, "result")); // 6

Jason  Jan 16, 2016  Apr 01, 2016
Printed
Page 920
3rd paragraph

The text indicates that a number is appended to the list every second, but the argument passed to Thread.Sleep is only 100 (milliseconds), which is one tenth of a second.

Note from the Author or Editor:
In 3rd paragraph on page 920, change "every second" to "every 100ms".

Jason  Feb 17, 2016  Apr 01, 2016
Printed
Page 1058
5th paragraph

The word "this" is missing from the following sentence: "We can fix (this) by calling NormalizeWhitespace..."

Jason  Sep 03, 2016  Apr 14, 2017
Printed
Page 1059
2nd paragraph in CSharpSyntaxRewriter section

The first sentence in this paragraph refers to the section on the CSharpSyntaxWalker class as "SyntaxSyntaxWalker".

Note from the Author or Editor:
Replace SyntaxSyntaxWalker with CSharpSyntaxWalker

Jason  Jun 30, 2016  Aug 12, 2016
Printed
Page 1059
4th paragraph

The output shown is inconsistent with the call to NormalizeWhitespace on unit, which would insert carriage returns in the following locations in the output: after the semicolon, after "Program" and after the opening curly brace.

Note from the Author or Editor:
The code listing should be formatted as follows:

var tree = CSharpSyntaxTree.Create (unit.NormalizeWhitespace());
Console.WriteLine (tree.ToString());

// Output:
using System.Text;

class Program
{
}

Jason  Sep 03, 2016  Apr 14, 2017
Printed
Page 1064
Code listing in 2nd paragraph

The expression location.MetadataModule == compilation.References.Single() evaluates to False, not True as indicated. This is consistent with the fact that the operands are of different types (IModuleSymbol and MetadataReference, respectively).

Note from the Author or Editor:
Thanks - will fix for next edition.

Jason  Sep 08, 2016 
Printed
Page 1070
1st code block

While it does not affect the example, in the Program class in which symbols are renamed, the Foo declaration and usages are not consistent. Either the Foo call in Main should be static since it is defined statically, or the signature of Foo should be changed so that it is in fact an instance method and the instance call in Main can remain. This latter option also requires a change to the static call to Foo in Bar.

Note from the Author or Editor:
Thanks, will fix for next edition.

Jason  Sep 20, 2016