Errata

C# 7.0 in a Nutshell

Errata for C# 7.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 52
Fourth paragraph

About the code snippet with real underscore variable in scope, the code will not compile because there is an out modifier missing in front of the underscore parameter and not because of the backward compatibility that the preceding paragraph seems to imply.

A better example in my opinion would have been:

string _;
Split("Stevie Ray Vaughan", out string a, out _);
Console.WriteLine(_);

in order to show that, in this case, the underscore is a real variable and not a discard.

Note from the Author or Editor:
Correct: change the example to the one suggested, so that:

string _;
Split ("Stevie Ray Vaughan", out string a, _); // Will not compile

becomes

string _;
Split ("Stevie Ray Vaughan", out string a, out _);
Console.WriteLine (_); // Vaughan

Luigi Valsecchi  Apr 13, 2019  Jun 21, 2019
Printed
Page 59
sixth line

I find it surprising to see Elvis listed among the "Unary operators." Surely it is binary.

Note from the Author or Editor:
The null-conditional operator (?.) should actually be in the *primary* category.

Move this table row to the second row in the table, below ". Member Access x.y"

Kim McCall  Feb 13, 2018  Sep 21, 2018
Printed
Page 60
Second actual paragraph

In discussing the ?? operator you say "If the operand is . . ., as though there were only one operand. I'd suggest "if the left operand " or "If the first operand."

Note from the Author or Editor:
“If the operand to the left is non-null, give it to me; otherwise, ...

Anonymous  Feb 13, 2018  Sep 21, 2018
Printed
Page 61
1st paragraph

Very minor issue. Since we're now on C# 7, I'd suggest changing "The ?. operator ... is new to C# 6" to "The ?. operator ... wasnew to C# 6" or (better) "The ?. operator ... is introduced in C# 6."

Note from the Author or Editor:
The ?. operator is the null-conditional or “Elvis” operator (after the Elvis emoticon), and was introduced in C# 6.

Kim McCall  Feb 13, 2018  Sep 21, 2018
Printed
Page 114
Paragraph beginning "Because both . . ."

You should remove the word "both."

Kim McCall  Feb 15, 2018  Sep 21, 2018
Printed
Page 123
3rd code bock

In the fourth line of the code, which is the assignment statement, you should make the second occurrence of "int" bold, too.

Kim McCall  Feb 15, 2018  Sep 21, 2018
Other Digital Version
170
1st example on public struct Point

You create 2 Point structures:
Point p1 = new Point(); // p1x and p1.y will be 0
Point p2 = new Point(1,1); // p1.x and p1.y will be 1

This is incorrect, p1.x and p1.y will be 0, p2.x and p2.y will be 1.

This was proved in debug mode in Visual Studio 2017.

Note from the Author or Editor:
Note that this is on page 110 of the printed edition.

The line in question should read:

Point p2 = new Point (1, 1); // p2.x and p2.y will be 1

Paul Tooley  Dec 07, 2017  Sep 21, 2018
Printed
Page 183
Examples in paragraph after the caution.

The comment, for the first line of example code, contains a typo.
The variable names, in the code, are "joe" and "bob". Where the comment refers to them as "joe" and "job".

var joe = bob; // joe is a *copy* of job

Should be:

var joe = bob; // joe is a *copy* of bob

Frank Robertson  Apr 19, 2018  Sep 21, 2018
PDF, ePub
Page 187
Named and Positional Attribute Parameters

There is an error in following code.

[XmlElement ("Customer", Namespace="...")]
public class CustomerEntity { ... }

I think it should be.

[XmlType("Customer", Namespace = "...")]
public class CustomerEntity { }

Note from the Author or Editor:
Correct. Also, in the preceding paragraph, change XmlElementAttribute to XmlTypeAttribute.

Ondřej Rada  Mar 27, 2019  Jun 21, 2019
Printed
Page 235 etc.
Last paragraph before "Comparing Strings"

The reference points to
"Formatting and parsing" on page 249,
where only DateTime formatting is discussed. It should instead point to
"Formatting and parsing" on page 256,
where general formatting is covered.

Same applies to
- page 249 itself (last paragraph before the scorpion) and
- page 230 (Fourth paragraph)
- page 247 (First paragraph - not shure with this one, though)

Wolfgang Jacques  Feb 20, 2019  Mar 15, 2019
PDF
Page 324
Figure 7-4

The arrows between the nodes have the wrong direction. Next pointers should point to the right direction and Previous pointers should point to the left.

Yang Shuai  Feb 06, 2019  Mar 15, 2019
PDF
Page 402
"Compiling expression trees" in Chapter 8.

There is an error in the top of the page. The brackets were forgotten while calling the method IsSelling.

IEnumerable<Product> localQuery =
localProducts.Where (Product.IsSelling.Compile());

IsSelling() should be written here, not IsSelling.

Note from the Author or Editor:
IEnumerable<Product> localQuery = localProducts.Where (Product.IsSelling().Compile());

Nahid Jamalli  Mar 10, 2019  Mar 15, 2019
Printed
Page 443
table at the bottom

Description for "AsEnumerable" method should be: "Upcasts to IEnumerable<T>" instead of "Downcasts to IEnumerable<T>". The description on page 446 is already correct: "AsEnumerable upcasts a sequence to IEnumerable<T>, ...".

Note from the Author or Editor:
Thank you. This will be revised in the next printing and online.

Dariusz Dacko  Mar 03, 2018  Sep 21, 2018
Printed
Page 599
1. text paragraph

...that initiate compute-bound currency... should be "concurrency"

Anonymous  Dec 14, 2018  Mar 15, 2019