Errata

C# 8.0 in a Nutshell

Errata for C# 8.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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page 50
2nd text paragraph of Indices sectoin

I think it would be clearer if this sentence:

"C# implements indices with the help of the Index type, so you can also do the
following:"

clarified that the Index type is a new type in implementations of .NET Standard 2.0 and above by rewording to:

"C# implements indices with the help of the new Index type, so you can also do the following:"

Otherwise it reads to me like they are utilising a pre-existing type.

Colin Hughes  Sep 11, 2020 
PDF Page 50
4th text paragraph of Ranges section

Same comment for Ranges as Indices comment above. Insert the word "new".

Colin Hughes  Sep 11, 2020 
Printed Page 60
First paragraph

The first sentence in the chapter 2 section titled "The in modifier" is missing a word (be). It says, "...the argument's value cannot modified by the method" and should probably be, "...the argument's value cannot be modified by the method."

Thank you for all the hard work that went into writing this fabulous book!

Kyle Thompson-Bass  Aug 09, 2021 
PDF Page 191
Nullable Reference Types (C# 8) section

Mentioning in the first sentence of the first paragraph that code works as before by default; i.e. assigning null will not raise a warning could be helpful.

Also, some recognition that the name of this .csproj element and accompanying directive can be confusing might help some, like me, who had to figure out that:

"#nullable enabled" translates to mean: nullable reference types (with the ? suffix) must be used explicitly within this code/block otherwise a warning will be raised.

It does not mean that nullable types can be used freely within this code/block.

(but, maybe, I'm still confused...)

Colin Hughes  Sep 14, 2020 
PDF Page 240
1st paragraph

You make it sound like ASP.NET Core can only be used in conjunction with React and Angular. It can't; it can, of course, be used with any JavaScript framework. Or, more accurately, any JavaScript web client (a framework isn't even required).

Colin Hughes  Sep 16, 2020 
PDF Page 265
Last code block

The result comments of IsDaylightSavingTime calls are the wrong way round if the calls are made in California. IsDaylightSavingTime returns False in the winter and True in the summer.

Colin Hughes  Jan 05, 2021 
PDF Page 323
paragraph between the two general notes

This sentence says: "For this reason, ICollection<T> does not extend ICollection, IList<T> does not extend IList, and IDictionary<TKey, TValue> does not extend IDictionary."

However:

IDictionary<TKey, TValue> does extend IDictionary.

Colin Hughes  Jan 18, 2021 
PDF Page 323
paragraph between the two general notes

My previous post saying "IDictionary<TKey, TValue> does extend IDictionary" while correct for .NET Standard appears to be incorrect for .NET Core. Which feels a little odd... The book is correct for .NET Core.

All according to the MS docs.

Colin Hughes  Jan 18, 2021 
PDF Page 324
first para under "ICollection<T> and ICollection" title

copy the collection into an array (ToArray)

should read:

copy the collection into an array (CopyTo),

Colin Hughes  Jan 18, 2021 
Printed Page 545
paragraph 9

The following code does not appear to behave as advertised when running under .NET Core 3.1:

var weak = new WeakReference(new StringBuilder("weak"));
Console.WriteLine(weak.Target); // weak
GC.Collect();
Console.WriteLine(weak.Target); // (nothing)

When I embed this code in a console application, two lines containing "weak" are printed instead of only one as expected. It appears that the garbage collector doesn't collect the StringBuilder.

Richard Hertzberg  Oct 15, 2020 
Printed Page 939
Bottom, last 2 Code examples

In the code examples there is an int[26] Array initialized, which limits the index from 0 to 25. Still in the code the index is checked like this:

index >= 0 && index <= 26, which will lead to an OutOfBounds Exception in case index is 26

comparing with < 26 would be correct.

Arne Lüdtke  Nov 11, 2020 
Printed Page 1008
2nd example

original code :

string regReplace =
@"<${tag}" + // <tag

should be modified to

string regReplace =
@"<${tag} " + // <tag


Whitespace should be inserted after '}' in the string "<${tag} ".

Lee, Sung Kyung  Jan 01, 2021