Errata

C# 10 in a Nutshell

Errata for C# 10 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
Chapter 2. C# Language Basics, Expressions and Operators (there are no page numbers)
In Table 2-3 (Operator Table)

In the "Category" column of Table 2-3, the three bitwise operators shown below are labeled as "Logical" instead of "Bitwise" (which were correctly labeled earlier in the chapter in Numeric Types -> Specialized Operations on Integral Type).

Category Operator Operator Example User-overloadable
symbol name
Logical And & And x & y Yes
Logical Xor ^ Exclusive Or x ^ y Yes
Logical Or | Or x | y Yes

Gary Ballance  Apr 04, 2022 
ePub Page Chapter 2 > Null Operators > Null-Conditional Operator
as described below

I really appreciate the link to Nullable Value Types and the preview

int? length = sb?.ToString().Length; // OK: int? can be null

BUT IT IS IN THE WRONG PLACE. Your first use of a nullable type occurs a few lines previous, which for me was on a previous kindle page:

char? c = foo?[1]; // c is null

It was a stumbler and I googled a while to get around what you nicely explain later. I suggest you move your explanation of nullable type up to the location where the concept is first used. Thanks!

Steve Pence  Jul 07, 2022 
ePub Page Chapter 9, Filtering
Table

The table has the same description for TakeLast and SkipLast, namely: "Takes only the last count elements". This seems to be an incorrect description for SkipLast.

Peter Benschop  Jan 15, 2023 
PDF Page p.82 (Chapter 2 > Statements > Selection statements)
1st line

For the switch statement, the author suggests using a discard (_) symbol, which is good, but it is also possible not to use any discard symbol to achieve the same result. Here's the book extract: "If you want to switch on a type, but are uninterested in its value, you can use a discard (_)
case DateTime _:"

This also works:
case DateTime:

Charles  May 04, 2023 
PDF Page p.130 (Chapter 3 Creating types in C# > Structs > Struct Construction Semantics > The default constr
2nd to last line

The following code returns a CS8983 error : A 'struct' with field initializers must include an explicitly declared constructor:

struct WebOptions { public string Protocol { get; set; } = "https"; }

(The author advises against this type of syntax anyway, but doesn't tell about the syntax error)

Charles  May 09, 2023 
PDF Page p.132, Chapter 3. Creating types in C# > Access modifiers
1st paragraph of the section

It reads "by adding one of five access modifiers to the declaration", but there are 6 of them listed.

Charles  May 09, 2023 
PDF Page 3
Memory Management's section, last paragraph

M: For performance-critical hotspots and interoperability, pointers and explicit memory allocation (is) permitted in blocks that are marked unsafe.

S: For performance-critical hotspots and interoperability, pointers and explicit memory allocation (are) permitted in blocks that are marked unsafe.

Anonymous  Jun 14, 2023 
PDF Page 44
Side note with crow

It says casting from float to int loses fractional part without rounding. I found this is true only up to 2 decimal points. As soon as I added 3 9s after decimal it started rounding in float and in int.

Bhavesh Mirani  May 28, 2023 
PDF Page 46
Keyword list

The keyword list doesn't include <<with>> keyword which is mentioned on page no. 29.

Bhavesh Mirani  May 26, 2023 
PDF Page 88
1st paragraph after code sample

It says "When you specify a constant, you’re restricted to the built-in integral
types; the bool, char, and enum types; and the string type." Actual it should say "... built-in numeric types;..." because switch works with real constants as well.

Bhavesh Mirani  May 30, 2023 
Printed Page 119
3rd paragraph

The Else keyword being used should be else, not Else. This refers to the code block following "The variable that you introduce is available for "immediate" consumption, so the following is legal:"

Eric Daniels  Jul 08, 2022 
PDF Page 274
7th Paragraph

Considering the statement "The Contains method doesn’t offer the convenience of this overload, although you
can achieve the same result with the IndexOf method." C# 10 does have this overload and this is possible => "abcdef".Contains("aBc", StringComparison.InvariantCultureIgnoreCase)

Muhammad Abdulmalik  Jan 05, 2023 
PDF Page 280
First code sample

Console.WriteLine ("ṻ".CompareTo ("ǖ")); // 0
Returns 1, not 0(zero).

Bhavesh Mirani  Jun 14, 2023 
PDF Page 301
IFormatProvider and ICustomFormatter

DateTimeInfo should be DateTimeFormatInfo.

Bhavesh Mirani  Jun 16, 2023 
Printed Page 302
Line 25

original: Indexof (digit), StringComarison.InvariantCulture);

should be: Indexof(digit, Stringcomarison.InvariantCulture);

Anonymous  Nov 07, 2022 
PDF Page 333
Last paragraph

Paragraph, copied below, seems to suggest that != of float returns false when comparing 2 float.NaN or 1 float.NaN with a float value. But when == returns false, != returns true when one or both are float.NaN.

"Although it’s possible to overload != such that it means something
other than !(==), this is almost never done in practice,
except in cases such as comparing float.NaN."

Bhavesh  Jun 26, 2023 
Printed Page 350
in the code of class Enumerator: public enumerator(...)

The constructor :

public Enumerator(MyIntList items) => this.items = items;

should be ...=>this.collection=items;

C. Li  Nov 09, 2022 
Printed Page 917
last code sample

WithDegreeOfPallelism(4) -> WithDegreeOfParallelism(4)

mdzieg  Aug 27, 2022