Errata

C# 8.0 Pocket Reference

Errata for C# 8.0 Pocket Reference

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
Null-Coalescing Assignment (C# 8)

The ??= Operator is described as assigning the variable only if its value is not null. Actually, it is the other way around. It is assigning only if the variables value is null. The example is wrong then, too:

if (s != null) s = "Hello, world"; (WRONG!)
if (s == null) s = "Hello, world"; (CORRECT! This is equivalent to ??=-Operator)

Note from the Author or Editor:
Yes: It should read as follows:

The ??= operator assigns a variable only if it’s null. Instead of this:

if (s == null) s = "Hello, world";

you can now write this:

s ??= "Hello, world";

Anonymous  Nov 05, 2019  Aug 21, 2020
Printed
Page 3
line 5 (first sentence of first paragraph)

First sentence of first paragraph begins:

Areturn types method can receive input data from ....

It should read:

A method can receive input data from ....

It looks as if the words 'return types' have been inserted erroneously into the sentence.

Anonymous  Dec 31, 2019  Aug 21, 2020
Printed
Page 59
1st paragraph under heading 'Switch expressions (C# 8)'

'Assuming *cardName* is of type int, …'

should read

'Assuming *cardNumber* is of type int, …'

Anonymous  Feb 13, 2020  Aug 21, 2020
PDF
Page 102
last section

In the following example, TextBox implements IUndo.Undo explicitly, and so it cannot be marked as virtual. To “override” it, RichTextBox must reimplement IUndo’s Undo method:

IUndo must be: IUndoable

Note from the Author or Editor:
Should read:

RichTextBox must reimplement IUndoable’s Undo method

Ron ter Borg  Dec 06, 2019  Aug 21, 2020
PDF
Page 194
code (middle)

static void Foo (int x) => Console.WriteLine ("int");
static void Foo (string x) => Console.WriteLine ("str");
static void Main()
{
dynamic x = 5;
dynamic y = "watermelon";
Foo (x); // 1
Foo (y); // 2
}

Shouldn't the returns be: "int" and "str" (instead of 1 and 2)?

Note from the Author or Editor:
Last three lines of code listing should read:

Foo (x); // int
Foo (y); // str
}

Ron ter Borg  Dec 09, 2019  Aug 21, 2020
Other Digital Version
215
Middle of page

Page 215 in the Kindle Reader version...

This code does not appear to work...

foreach (IEnumerable < Purchase > purchaseSequence in query)
foreach (Purchase p in purchaseSequence)
Console.WriteLine (p.Description);

These changes are needed...

1) The data definitions needs a concrtete "Purchase" type, not anonymous.
2) p.Description should probably be p.Product


Note from the Author or Editor:
Thanks - I'll fix this in the next edition.

Bob C  Sep 22, 2020