Errata

C# 12 in a Nutshell

Errata for C# 12 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
Other Digital Version Chapter 2 "Compilation"
dotnet new Console -n MyFirstProgram

The code to create the first project folder and file has a small typo. This line of code: dotnet new Console -n MyFirstProgram
should be changed to: dotnet new console -n MyFirstProgram
On my Windows 11 pc the template Console App is created with a lowercase 'c' rather than capital 'C'.

Here is a log of my PowerShell session:

PS C:\Projects> dotnet new Console -n MyFirstProgram
No templates or subcommands found matching: 'Console'.
Did you mean one of the following templates?
dotnet new console

To list installed templates similar to 'Console', run:
dotnet new list Console
To search for the templates on NuGet, run:
dotnet new search Console


For details on the exit code, refer to <url-hidden>
PS C:\Projects> dotnet new console -n MyFirstProgram
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring C:\Projects\MyFirstProgram\MyFirstProgram.csproj:
Determining projects to restore...
Restored C:\Projects\MyFirstProgram\MyFirstProgram.csproj (in 94 ms).
Restore succeeded.



Anonymous  Dec 25, 2023 
PDF Page p. 585
In code under "Anonymous Disposal" title.

Inside the "class Foo" here is mentioned that "int _suspendCount;". Which in C# mean that "_suspendCount" field is "private", but in the next page inside "class SuspendToken" with the object of "class Foo" by the name "_foo" mentioned call of this private field:

if (_foo != null) _foo._suspendCount--;

It can happen only when "class SuspendToken" is nested for "class Foo"... which is not apparent from text.

Thank you.

Suren Edilyan  Mar 03, 2024 
Other Digital Version 119
Section "Ranges", 2nd paragraph

Using the Kindle version of the book.

You state that the 2nd number in the range is exclusive, but don't mention that the first number in the range is inclusive. That, coupled with the example using "2", caused confusion for me as I incorrectly assumed you were saying that the numbers in the range are exclusive. I puzzled over the results of your example for a long time until I looked up the Microsoft Learn tutorial article "Explore indexes and ranges", which explains that "A range specifies the start and end of a range. The start of the range is inclusive, but the end of the range is exclusive, meaning the start is included in the range but the end isn't included in the range."

Bryan H. Bell  Dec 10, 2023