Errata

Head First C#

Errata for Head First C#

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, PDF, ePub, Mobi, , Other Digital Version
Page Multiple pages
Multiple locations

Shortly after the 4th edition went to print, the WPF project type in Visual Studio 2019 changed from "WPF App (.NET Core)" to "WPF App (.NET)", so we needed to make the following changes:

Page 8: Change the text: "select WPF App (.NET Core)"
to: "select WPF App (.NET)"

Page 8: Replace the second and third screenshots on the page with a current screenshot from Visual Studio 2019

Page 26: The "Start button" screenshot

Page 26: In the box, change: "When your program first runs, you’ll see"
to: "When your program first runs, you might see"

Page 73: Change "Select WPF App (.NET Core)"
to: "select WPF App (.NET)."

Page 73: Updated screenshot

Page 120: Change "Select WPF App (.NET Core)"
to: "select WPF App (.NET)."

Andrew Stellman
Andrew Stellman
 
Dec 17, 2020  Dec 18, 2020
Printed
Page xxxiv
6th paragraph

The word "the" appears wrong. The 'e' in the line "benefits from seeing the same content represented in multiple ways" is covered by the background of the graphic "bullet points".

Anonymous  Jan 01, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page xxxviii
Annotation that starts

Add the names Srikar Thottempudi, Mike Olgren, and Jim Cupec to the list of wonderful readers who we thank.

Andrew Stellman
Andrew Stellman
 
Feb 20, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page Multiple pages
Fixing small typos on multiple pages

Combining fixes to small typos into a single errata entry.

129 - In step 1: "Enemy array called enemies" – change "enemies" to "enemyArray"

133 - In the top part of the class diagram box in the lower left of the page, change "Enemies" to "enemyArray"

146 - In the last sentence of Step 3, delete the following text: ", which returns the amount of cash he received"

146 - In the annotation at the bottom of the page, delete the following text: "—then returns the number of bucks added"

162 - Delete the sentence: "Add a D (or leave off the suffix entirely) and the error goes away."

254 - In the top paragraph change "they property" to "the property"

306 - In the box on the bottom right of the page, in "This updated version of the method in the base class" change "base class" to "Chameleon class"

307 - Remove the following text that appears about two thirds of the way down the page: "—now the Main method compiles just fine"

332 - In the last line of the box, change "from its WeaponDamage method." to "from its constructor."

337 - In the third paragraph, change "no method body that must be implemented" to add an em-dash and "the" between "body" and "that" so it reads like this (keep the formatting the same, the word "the" is not bold or italic): "no method body—the body must be implemented"

337 - In the sidebar ("If an abstract class has virtual members") change the word "virtual" to "abstract"

339 - In the second question, change "Some of the abstract classes" to "Some of the abstract methods"

340 - In the first sentence of the second paragraph, change "convert to an abstract class" to "convert to an abstract method"

350 - At the bottom of the page, change "look closely the AddABall method" to "look closely at the AddABall method"

356 - Change "butany" to "but any" in the last paragraph

358 - Change the first line of code at the bottom of the page to:
Bee worker = new NectarDefender();

376 - In the third annotation, change "hasits" to "has its"

379 - In the first sentence of the last paragraph, change "and it works no matter what other classes that object implements" to "and it works no matter what other interfaces that object implements or what class it's an instance of"

380 - In the first boldfaced line, change "safely convert a NectarCollector" to "safely convert a HoneyManufacturer"

383 - Change two occurrences of "mrCoffee" to "misterCoffee" – the first isin the third line of code on the page, the second is in the last line of the top annotation.

383 - In the "Sharpen Your Pencil" solution, change the first answer to: "0, 2, 5, and 6" and change the first part of annotation that points to it to: "Elements 0, 2, 5, and 6 in the array"

385 - In the illustration in the middle of the page, change the text on the post-it note from "power Consumer" to "some Appliance"

386 - In the top paragraph, remove this text: ", a Microwave reference,"

389 - In the second star bullet, change "that implements IScaryClown" to "that implements IScaryClown and extends FunnyFunny"

397 - In the second star bullet, change "private static random field" to "static random field"

407 - In the third checkmark bullet, change "Suit enum" to "Suits enum"

414 - In the box in the upper right corner, capitalize Egg in "new List();"

431 - In the first sentence ("in this case, Duck") change Duck to DuckComparerBySize

431 - In the second annotation (""You'll pass Sort a reference") add a comma after Sort

434 - In the top annotation, change "first compares their values, then their suits" to "first compares their suits, then their values"

438 - In the second bullet in "Sharpen your pencil" swap -1 and 1, so the sentence reads: "1 if the other breed was greater and -1 if the other breed was less"

438 - In the first bullet ("angle brackets with a comma-separated list of objects") change "angle brackets" to "curly brackets"

441 - Add an annotation next to the first screenshot which has two hand-drawn underlines: "We named our project BirdCovariance when we took this screenshot. You'll see your project's name in the error message instead."

441 - In the last sentence of step 3, change "safely upcast our List to a List?" to "safely upcast our collection of Duck references to a more abstract collection of Bird references?"

447 - In the code comment "Pop pulls the next item from the BOTTOM of the stack" change the word BOTTOM to TOP

452 - Add an annotation at the bottom of the page under the box pointing up at it that says: These downloadable exercises are not optional—they're an important part of the learning path.

453 - the word "create" is misspelled in "using a prefab to crate GameObject"

460 - In the second paragraph change "Click on it and set its text" to "Click on it and use the Inspector to set its text"

474 - In the second annotation on the right, change "{100, 101, 102, 103, 104}" to "{5, 6, 7, …, 102, 103, 104}"

475 - In the third paragraph, add a comma after "query" to change "what object to query how to determine" to "what object to query, how to determine"

Andrew Stellman
Andrew Stellman
 
Mar 10, 2021 
Page n/a
text

Current Copy:
Relational Operators Use > and < to compare numbers and see if a number in one variable one is bigger or smaller than another.

Suggested:
"number in one variable one is bigger or" should be "number in one variable is bigger or"



Note from the Author or Editor:
Fixed typo on page 62

Anonymous  Nov 01, 2021 
Page n/a
text

Current Copy
a Click event handler to your Button control. The code-behind — tthe C# code in MainWindow.xaml.cs that’s joined to your XAML —

Suggested
change "tthe" to "the"

Note from the Author or Editor:
Fixed typo on page 124

Anonymous  Nov 01, 2021 
ch 1 (no page numbers listed)
`"There are no dumb questions" section at end of section on "Add your project to source control"

There might be some confusion around the below section:

"There are no dumb questions"

Q: I assumed XAML was like HTML, which is interpreted by a browser. XAML isn’t like that?A: No, XAML is actually code that’s built alongside your C# code. Back at the beginning of the chapter we talked about how you could use the partial keyword to split up a class into multiple files. That’s exactly how XAML and C# are joined up: the XAML defines a user interface, the C# defines the behavior, and they’re joined up using partial classes.That’s why it’s important to think of your XAML as code, and why learning XAML is an important skill for any C# developer.

The issue here is that partial classes are not discussed until after this particular section. Doing a search of the keyword "partial" shows the first occurrence at this section.

David Horton  Nov 28, 2020  Dec 18, 2020
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 4
Step 1

When you create your new project, Visual Studio asks which version of .net to use. I didn’t understand what to do since I don’t know the implications of the different versions.

Note from the Author or Editor:
Change this: "Name your project MyFirstConsoleApp and click the Create button."

To this: "Name your project MyFirstConsoleApp and click the Next button, then click the Create button."

(put both Next and Create in boldface)

Jim Cupec   Feb 25, 2021 
Page 8
second screen shot image

The WPF App selection title (after choosing Create a new project) has changed again. The button now reads "WPF Application." There is nothing in parentheses after the title. The descriptor text has changed to "A project for creating a .NET Core WPF Application."

This is true for the other similar screen shots in the book. This errata would replace the previous errata.

Note from the Author or Editor:
Also fixed similar issue on pages 73 and 120

Mike Olgren  Mar 11, 2021 
Page 22
Step 2

redundant semicolon in " public MainWindow(); "

Note from the Author or Editor:
Thanks for pointing this out!

Ruey-Cherng Yu  May 22, 2022 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 30, 31, and 47
Full pages

Shortly after the 4th edition went to print, the Visual Studio team made significant (and really great!) changes to the Git-related features in Visual Studio 2019. We made extensive updates to pages 30, 31, and 47. The updated versions in the free PDF of chapters 1-4, which you can download from our GitHub page: https://github.com/head-first-csharp/fourth-edition

Andrew Stellman
Andrew Stellman
 
Dec 17, 2020  Dec 18, 2020
Page 44
comment toward bottom of box explaining foreach

In the comment it says "...it sets oneNumber to the next number..." This should be "...it sets aNumber to the next number..." There is not a variable named oneNumber.

Mike Olgren  Mar 10, 2021 
Page 60
top images

The icons used by Visual Studio for Step Into, Step Over, and Step Out have changed, so they are different from what is shown in the images underneath the first paragraph.The new images use simpler dots and arrows.

Mike Olgren  Mar 11, 2021 
Page 65
bottom right corner "Hint"

The "Hint" for Loop #3 in the Sharpen your pencil" box calls "p = p * 2" the iterator. Isn't this a statement in the while loop? Isn't "q = q * 2" the only iterator in this code example? In either case, I'm not sure this was helpful to me. Pointing out that the "q = p - q;" statement sometimes results in zero is helpful. However, deleting the words "the iterator" might solve this, unless the intent was to use q instead of p.

Mike Olgren  Mar 11, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 77
Note with arrow at bottom left of page

To make sure the reader gets the exception so they can fix it, change the text: "And the XAML code that appears inside the <Grid> after the row and column definitions and before the </Grid> should look like this:"

To: "Make sure the XAML code inside the <Grid> after the row and column definitions and before </Grid> looks like this, with the Label control first, then the TextBox, then the TextBlock:"

Andrew Stellman
Andrew Stellman
 
Dec 31, 2020 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 77 and 78
Entire page

The steps on pages 77 and 78 were accidentally left in the wrong order. This PDF the correct order: https://github.com/head-first-csharp/fourth-edition/raw/master/Additional_material/Corrected_pages_77_and_78.pdf

Andrew Stellman
Andrew Stellman
 
Jan 30, 2021 
Printed, PDF
Page 77
Bottom of Sleuth it Out box

On page 77 of the the original Print Edition or page 78 of the corrected PDF, the last line on the page says "... and the TextBox now only accepts numeric input." That's not true, alphanumeric characters are accepted. At this point, we have done nothing to the control to restrict the type of input.

Note from the Author or Editor:
Remove the text ", and the TextBox now only accepts numeric input" from page 78.

Jim Cupec  Feb 26, 2021  Jun 15, 2022
PDF
Page 79
Step 3.

3. If the user entered a number, it sets e.Handled to true, which tells WPF to ignore the input.

If the user entered a NON-NUMERIC character, then the line is correct. If the user entered a NUMBER, e.Handled is set to false.


Note from the Author or Editor:
This line should say:

3. If the user entered a non-numeric character, it sets e.Handled to true, which tells WPF to ignore the input.

Anonymous  Jan 11, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 84
Code in step 1 and Step 3

Why do we need the "if" statements in the event handlers? I tried to delete them and it didn't recognize the signaler of the event as an identifier. Is this because we did not name the ListBox and the RadioButton?

Note from the Author or Editor:
Add an annotation to the bottom of page 84 with an arrow pointing up at the bottom block of code: "Wondering why you need that if statement in the ListBox event handler? You'll learn about it when we talk about the 'is' keyword in Chapter 7."

Jim Cupec  Feb 27, 2021 
Page 122
Fourth bullet in step 2

In the 4th bullet it says to "expand the Layout section" to set the IsSnapToTickEnabled property to True. This property is in the Common section, so just change "Layout" to "Common." [I found it by using the Search box method taught earlier.]

Mike Olgren  Mar 15, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 123
Step 5, second bullet

There's a typo in the second bullet in step 5 on page 123. The bullet should say:
* Use the Layout section to set the height to 300 and the width to 800.

Andrew Stellman
Andrew Stellman
 
Dec 27, 2020 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 147
Summary section of ReceiveCash method

Very minor detail, but the comment supplied for the amount parameter in the summary states "Amount of cash to give." It should say "Amount of cash to receive."

Note from the Author or Editor:
In this part of the code above the ReceiveCash declaration near the bottom of the page:

/// <param name="amount">Amount of cash to give.</param>
public void ReceiveCash(int amount)

change "Amount of cash to give." to "Amount of cash to receive."

Mitchell Schaff  Feb 26, 2021 
Page 148
4th paragraph

In the line : "Choose the Name field, set it to 50 and add a comma:"
you clearly meant : "Choose the Cash field, set it to 50 and add a comma:"

Maxime Collin  Apr 23, 2022 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 157
"Character sheet" graphic

The box next to Strength has the number 911, and the box next to Dexterity is empty. These should be changed: the box next to Strength should have the number 12, and the box next to Dexterity should have the number 15.

Andrew Stellman
Andrew Stellman
 
Feb 04, 2021 
Page 160
Floating-Point Numbers Up Close

Hi,

I think that there are not IsFinite method for float and double data types.

I think that the corret code is some kind of not IsInfinity like:

for (float f = 10; !float.IsInfinity(f); f *= f)
{
Console.WriteLine(f);
}

for (double d = 10; !double.IsInfinity(d); d *= d)
{
Console.WriteLine(d);
}

Eduardo Rodrigues  Apr 19, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 162
2nd section

The text in the "Using Suffixes" section refers to actions taken in the Unity labs:

"InvokeRepeating("AddABall", 1.5F, 1)"

(specifically with respect to literals). In Unity Lab 1, however, there was no C# code involved.

Note from the Author or Editor:
In the the "Use suffixes to give your literals types" section on page 162, change the first line of text to this, making the uppercase D in 10D bold and underline:
Go back to the first loop you wrote in the "Up Close" section and change 10 to 10D:

Change the line of code under it to this, making the uppercase D in 10D bold and underline:
for (float f = 10D; float.IsFinite(f); f *= f)

In the paragraph that follows that line of code, change the first sentence to this:
Now your program won't build—you'll get an error that mentions a "literal of type double.

Mitchell Schaff  Feb 27, 2021 
Printed
Page 166
Arrowed text on first figure

The text says float, double and decimal are for fractions. That is true, but it is also to store very large numbers that do not have fractions, e.g., 6023 x 10^20.

Note from the Author or Editor:
Change the top annotation on the page to: "These types are for fractions. They can also be used to store very large numbers. Larger variables store more decimal places."

Jim Cupec  Feb 28, 2021 
Page 166
Last text of the page with an arrow pointing to the string cup

It says that max length of a string is 2^31, which is 2147483648. However, if it's using the int type, then max length should be 2147483647?

Anonymous  Jan 29, 2023 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 167 and 483
"Sharpen" on 167, code on 483

Change this: int radius = 3;
To this: int radius = 3;

And add an annotation pointing to that line on 483: "If you wanted to define this as a long, you could replace 3 with 3L."

Andrew Stellman
Andrew Stellman
 
Mar 28, 2022 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 169
1st paragraph

In the line "256 cast to a byte will have a value of 0, 25 will be converted to 1"

It should be 257 will be converted to 1

Note from the Author or Editor:
Fix the typo: change "25 will be converted to 1" to "257 will be converted to 1"

Anonymous  Jan 20, 2021 
Page 169
first sentence

The first sentence appears to refer to the example on the top of the previous page (168; see previously entered errata). That example cast a float to an int. Would change the first sentence to correspond: "You've already seen that a float can be cast to an int."

Mike Olgren  Mar 17, 2021 
Page 172
2nd-to-last paragraph

Change "between parameter" to "between a parameter"

Anonymous  Apr 27, 2021 
Page 177
second sentence

The second sentence lists the fields starting with "Starting4D6Roll." In the code below, this field is named "RollResult." Fix by replacing "Starting4D6Roll" with "RollResult."

Mike Olgren  Mar 17, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 188
Bullet 2

Guy bob... Cash = 100,...
But the graphic states "Bob" 75 - 75 should be 100?

Note from the Author or Editor:
In the graphic at the bottom of the page, change the number under "Bob" from 75 to 100. Make corresponding changes to the two graphics on page 189.

James Foster  Jan 15, 2021 
Page 195
Bullet point 4

"When the user presses 3, make the app call a method that exchanges the two references"

The solution on the following page does not use a method or function to swap the references.

Anonymous  Jul 07, 2021 
Page 200
3rd paragraph

In the 3rd paragraph, the 2nd sentence. This statement sets the value of the fifth element of myArray to true.
Actually, it is set to false.

Chao  Sep 29, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 208
Last Box paragraph

This method makes a random price between 2.01 and 5.97 by converting two
random ints to decimals. --> This method makes a random price between 2.01 and 4.97 by converting two random ints to decimals.

Note from the Author or Editor:
Fix the typo by changing 5.97 to 4.97 in the box at the bottom of page 208, and also in the box at the bottom of page 720.

Eddy Eui Soon Hwang  Jan 15, 2021 
Page 208
2nd paragraph

2nd sentence in the second paragraph starts with "It has four fields..." The MenuItem class diagram pictured on the right has six fields (Randomizer, Proteins, Condiments, Breads, Description, and Price).

Mike Olgren  Mar 24, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 210
Last line of the MakeTheMenu method

Change the last line of the MakeTheMenu method from this:
guacamole.Text = "Add guacamole for " + guacamoleMenuItem.Price;

to this:
guacamole.Text = "Add guacamole for " + guacamolePrice;

The code still functions exactly the same, but this is clearer to the reader.

Andrew Stellman
Andrew Stellman
 
Dec 29, 2020 
Page 216
graphic, text ballon pointing to 8 ball

As explained on the next page, the ball will rotate once every two seconds (180 * Time.deltaTime). The last part of the text balloon pointing at the 8-ball says "...a speed of two rotations per second" but should say "...a speed of one rotation per two seconds."

Mike Olgren  Mar 25, 2021 
Page 234
but it doesn’t add the extra 3 HP for flaming, but in code flaming damage is 2

typo

Note from the Author or Editor:
On page 234 in the third paragraph, in the phrase "it doesn't add the extra 3 HP for flaming" change 3 to 2

littlefox  Oct 23, 2022 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 236
Bottom of page

Add a boldfaced note in Arial Black (style "Learner Answer") to the bottom of the page that says this (with the word "after" underlined):

Now we know what caused the bug! We won’t fix this project yet.
We’ll return to fix the project after learning more about encapsulation.

You can see an image of how this should look here: https://raw.githubusercontent.com/head-first-csharp/fourth-edition/master/Additional_material/Updated_page_236.png

Andrew Stellman
Andrew Stellman
 
Feb 17, 2021 
Page 244
Hint method

Since I am a beginner studying C# I apologize if my explanation is lackluster.
Same result was reached using my own and the code from Head First github.


HiLoGame

The "Hint" method give false hints. I think the "currentvalue" has yet to been updated to "nextnumber" when hint method performs the if loop "if (currentNumber >= half)".

Example from the game:

The current number is 5
Press H for higher, L for lower, ? to buy a hint,
or any other key to quit with 10.
(I press "?")
The number is at least 5
Press H for higher, L for lower, ? to buy a hint,
or any other key to quit with 9.
(I press "H")
Bad luck, you guessed wrong!
The current number is 1
Press H for higher, L for lower, ? to buy a hint,
or any other key to quit with 8.





Note from the Author or Editor:
I made several changes to this exercise to correct the problem, and also simplify the approach. The updated version of these pages can be found here: https://github.com/head-first-csharp/fourth-edition/raw/master/Additional_material/Corrected_pages_243_and_244.pdf

(O'Reilly production team: I can provide the updated InDesign files for these pages)

Kristen Kuldmaa  Aug 03, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 259
The error that is displayed in the main method

After adding the constructor, the main method will throw the error. The displayed error has MachineGun class, but the actual class name is PaintballGun.

Note from the Author or Editor:
Replace the screenshot on page 259 with this image: https://raw.githubusercontent.com/head-first-csharp/fourth-edition/master/Additional_material/Corrected_error_message_pages_259_and_260.png

Anonymous  Feb 15, 2021 
Page 259
last statement in constructor image

The last statement of the PaintballGun constructor is:
if (!loaded) Reload();
When the used enters that the paintball gun is loaded (typing "True" at the prompt, this code will result in an unloaded gun ["20 balls, 0 loaded"].
To fix, delete the ! ("not" operator) before loaded for the if conditional test:
if (loaded) Reload();
This will then "load" the gun that starts empty.

Mike Olgren  Apr 03, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 260
Wrong class name is used in the error that is displayed in the first paragraph

The error displayed has the wrong class name "Machinegun" instead of "PaintballGun".

A couple of lines later, the code is instantiated again using "Machine gun" instead of "PaintballGun".

Note from the Author or Editor:
Replace the screenshot on page 260 with this image: https://raw.githubusercontent.com/head-first-csharp/fourth-edition/master/Additional_material/Corrected_error_message_pages_259_and_260.png

Anonymous  Feb 15, 2021 
Page 265, 266
Solution of "price = Price;" statement

Solution says change the statement to Price = price, but the Price property that defined in class GumballMachine (page 265) doesn't have setter.

Note from the Author or Editor:
Thanks for spotting this. Yes, you're right – the text explaining the answer to the exercise needs to be updated. We should change the following text:

"If you flip this around to set Price = price, it will work."

To this:

"We could flip this around to set Price = price, but that's not enough to fix the bug. What else would we have to do?"

Thong Nguyen  Aug 13, 2022 
Page 271
Across #7

It looks like the escape sequences were not printed in the question.
"What kind of sequence is or ?"

Perhaps it meant to represent " " and " ". Or someone directly typed /n and /t.

Note from the Author or Editor:
Fixed the clue for #7, which was missing backslashes due to a printing error:

7. What kind of sequence is \n or \r?

David Horvitz  Dec 21, 2021 
Page 271
Down #10

There's a grammatical error.
"What you're doing when..." would be answered with a noun.

I suggest "To ____ two strings, use the + operator."

David Horvitz  Dec 21, 2021 
Page 275
4th line

weaponKey has no type, s/b "char"

david  Dec 21, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 289
Last but one bullet point

The last but one bullet point mentions that "Always use a subclass reference in place of base class.". The wording should be "You can always use a subclass reference in place of base class.".

Note from the Author or Editor:
Change the bullet "Always use a subclass reference in place of base class." to "You can use a subclass reference in place of base class."

Anonymous  Feb 16, 2021 
Page 290
bottom section

Console.Write(tweety.Eat());
this causes a compile error as the Eat method returns void

I suggest adding a return to the method and changing it to string or getting rid of the line

david  Dec 21, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 317
Queen class model

The Queen class model on page 317 doesn't include a method for AddWorker, UpdateStatusReport or WorkerStatus.
In the instructions for writing the classes on page 321, there are instructions for building all methods except for the WorkerStatus method. There is no mention of this method until you look at the answer.

Note from the Author or Editor:
On page 317, add the following sentence to the end of the annotation pointing up at the Queen class: "Queen also has private methods, which we'll talk about later."

On page 321, update the last bullet in the first section that starts "Look carefully at the status reports in the screenshot" to add the following sentence to the end:

UpdateStatusReport calls a private WorkerStatus method with a string parameter called job ("Nectar Collector") and returns a string with the number of workers doing that job ("3 Nectar Collector bees").

Amy Jenkins  Mar 30, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 320-321
Multiple locations

There were a few uncorrected typos in the instructions for the Beehive Management System exercise on pages 320 and 321:

page 320: At the end of the fourth bullet in the top section, change workers.Length to unassignedWorkers – so it should read: "Then she calls HoneyVault.ConsumeHoney, passing it the constant HONEY_PER_UNASSIGNED_WORKER (set to 0.5f) × unassignedWorkers."

page 320: In the third bullet, change ""is less than the nectar left in the vault"" to "is greater than the nectar left in the vault"

page 320: In the fourth bullet, change "If it’s greater than the honey field" to "If honey is greater than or equal to amount"

page 320: In the fifth bullet, change "it adds it to the honey field" to "it adds it to the nectar field"

page 321: In the first bullet under "Build the code-behind for the main window" change the following text: "that’s initialized in the constructor"
to this: "that's initialized with a new Queen instance"

Andrew Stellman
Andrew Stellman
 
Apr 17, 2021 
Page 358,359
various

If I'm not mistaken, there is an error where the interface is referred to as "Idefend" on 358 but "Idefender" on 359 (and thereafter).

david  Dec 30, 2021 
Page 371-372
Last sentence under "Here's what you need to do" (371), The exercise solution for Queen.cs (372)

On page 371, the last sentence says, "After you add the interface, you only need to change one line of code in the Bee class and three lines of code in the Queen class", since the third bullet point states to replace any Bee reference with an IWorker reference. I believe this may be incorrect as there are 4 Bee references on Queen.cs which would mean 4 lines of code would need to be modified.

On 372, under the Queen part of the solution we see 3 of the Bee references updated to IWorker but the one that is missing is in the DoJob method inside the foreach statement.

" protected override void DoJob()
{
eggs += EGGS_PER_SHIFT;
foreach(Bee worker in workers) // this is the line
{
worker.WorkTheNextShift();
}
// rest of the method
}
"

Was it intentional to leave the Bee reference in that foreach statement or is this something that may have been missed?

Note from the Author or Editor:
Thanks, good catch! You're right, I missed that one. I've fixed this for future printings by changing "three lines" to "four lines" on page 371, and adding a box on page 372 to point turn this into a little mental exercise:

There’s one more Bee reference in the Queen.DoJob method:
foreach (Bee worker in workers)
Your code still runs whether or not you change it to IWorker. Why do you think that is?

Chris Jackson  May 23, 2021 
Page 376
2nd

abstract class Canine : Animal
{
public bool BelongsToPack { get; protected set; } = false;

}
}
The book sayed it has its own abstract property, BelongsToPack, but why abstract modifier didn't appear before BelongsToPack ,Thanks

Note from the Author or Editor:
That's a great question. You don't need the 'abstract' modifier because in an abstract class, every member is automatically abstract.

We can update the annotation that points to "abstract class Canine : Animal" to say the following:

The abstract Canine class extendsAnimal. It has its own abstract property, BelongsToPack. We don't need to label it abstract because in an abstract class, every member is automatically abstract.

nickfox  Oct 31, 2022 
Page 394
bottom Watch it!

I think it's a good idea to note that WPF projects and Unity will only use 7.3, so Interface default implementation will not be possible for them. The Bee project will give an error, too, all WPF seem to use .NET Framework which is C# 7.3

I found this relevant chart:
╔══════════════════╦═════════╦═════════════════════════════╗
║ Target framework ║ version ║ C# language version default ║
╠══════════════════╬═════════╬═════════════════════════════╣
║ .NET ║ 6.x ║ C# 10 ║
║ .NET ║ 5.x ║ C# 9.0 ║
║ .NET Core ║ 3.x ║ C# 8.0 ║
║ .NET Core ║ 2.x ║ C# 7.3 ║
║ .NET Standard ║ 2.1 ║ C# 8.0 ║
║ .NET Standard ║ 2.0 ║ C# 7.3 ║
║ .NET Standard ║ 1.x ║ C# 7.3 ║
║ .NET Framework ║ all ║ C# 7.3 ║
╚══════════════════╩═════════╩═════════════════════════════╝

Note from the Author or Editor:
Added a link to the page with that table – thanks!

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version

david  Jan 05, 2022 
Printed
Page 406
Second code snippet

Console.WriteLine(aceOfSpades); // prints Ace of Spades

the above statment will not print ace of spades.

Console.WriteLine(aceOfSpades.Name); will print the output mentioned.

Note from the Author or Editor:
Change "aceOfSpades" to "aceOfSpades.Name" in the following line of code:
Console.WriteLine(aceOfSpades); // prints Ace of Spades

Anonymous  Feb 28, 2021 
Page 416
middle, right column

the solution for how to do .Contains with an array assigns the value to "isIn" which is a new unspecified variable. It should assign true to foundIt.

david  Jan 06, 2022 
Page 426
code examples

The enum for Style from page 417 does not use plural s, but here it says things like "Style.Sneakers"

david  Jan 10, 2022 
Page 426
code examples

It's not mentioned here, but this shoe collection initializer will not work with the previously given code, as the Shoe class has private stters for Style and Color and also requires parameters for style and color.

Note from the Author or Editor:
Updated the code so it doesn't use object initializers

david  Jan 10, 2022 
Page 452
2nd-to-last paragraph

Change "Go ahead and an" to "Go ahead and". Also in the bottom-right note it looks like it says "Deek 2" instead of "Deck 2".

Anonymous  Apr 27, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 502
Step 1

Microsoft changed the project name from MSTest (.NET Core) to Unit Test Project after the first printing of the book, updated this step to reflect that change.

Andrew Stellman
Andrew Stellman
 
Apr 18, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 512
Sharpen Your Pencil Solution

In the suggest solution to the NectarCollector Bee, you left out the override keyword. This hides the property, not overrides it.

Also, why isn't the answer just

public override float CostPerShift =>1.95f;

?

Note from the Author or Editor:
Change the first hand-written answer in the "Sharpen Your Pencil" solution on page 512 to:

public override float CostPerShift =>1.95f;

Jim Cupec  Mar 24, 2021 
Page 526
4th bullet point

"The internal keyword makes classes in one project accessible to another project in a multiproject build" -> change "accessible" to "inaccessible"

Jermaine Martin  Jan 15, 2022 
Page 549
lower right box

Should be "i > 9" (or i >= 10) instead of "i > 10" in the for loop to create a deck with 10 cards. Index of deck starts at 0.

Jermaine Martin  Feb 09, 2022 
Page 556
Bottom of page

The graph diagram at the bottom of the page, the Guy objects hair colour are the wrong way round. Joe should be Gray and Bob should be Red.

Also should the graph diagram not show the HairStyle objects connected to the Guy objects, not shown in the Guy objects themselves, as they do for the outfit objects?

Anonymous  Jan 25, 2022 
Page 605
Codeblock beneath first paragraph

The method 'FeedDog' assigns the return value of the method 'Eat' to the variable 'eaten'. That's not possible -> The method 'Eat' does not return a value.

Jermaine Martin  Apr 27, 2022 
Page 607
Codeblock

class Guy's ToString method does not fit the console output.
It should write the following output:

i is 1 and guy is a 26-year-old named Joe
i is 11 and guy is a 37-year-old named Bob

Jermaine Martin  Apr 27, 2022 
Page 616
above "Sharpen your pencil" solution

It says:
Since the Lamp method takes an object parameter, boxing automatically happens when it's passed an int or a string.
That is not right, string is a reference type, so it does not get boxed.
Definition of boxing:
The conversion of a value having some value type, to a newly allocated instance of the reference type System.Object.

Jermaine Martin  Apr 28, 2022 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 662
Bottom of page where we recommend C# 8.0 in a Nutshell

"C# 9.0 in a Nutshell" is now out! Update the image of the book cover to match the new edition, and modify the lower right annotation to change "8.0" to "9.0".

Andrew Stellman
Andrew Stellman
 
Mar 13, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 679
Paragraph text of step 4

Change this text:
Start by adding a @code block to the end of your Index.razor file. Go to the last line and type @code {. The IDE will fill in the closing curly bracket } for you. Press Enter to add a line between the brackets, then:

To this:
You're adding code to store a pairs of animal emoji that the player will match. Make sure your cursor is at the end of the line you just added, then:

Andrew Stellman
Andrew Stellman
 
Feb 20, 2021 
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 695
Text under Step 5

These changes update the debugging in the Visual Studio for Mac appendix to make it easier for the reader to use.

Replace this sentence near the bottom of the page: "Press Step Over one more time to execute the statement that removes the matches from the list."

With this:
Continue Execution to resume your game, then click another matched pair of animals to trigger your breakpoint again and return to the debugger.

(set "Continue Execution" and "click another matched pair" in boldface)

Andrew Stellman
Andrew Stellman
 
Dec 17, 2020  Dec 18, 2020
Printed, PDF, ePub, Mobi, , Other Digital Version
Page 712
Middle of text snippet on top half of page

The quote in the textbox in the middle of the snippet says, "the buttons are…colored differently (that's what btn-secondary does)." I've tried using Chrome and Safari for the Mac and they both appear as a sort of grayscale and all the same color.

Not sure if this should be a technical mistake or a language change of some sort.

Note from the Author or Editor:
Change "colored differently" to "shaded differently in some browsers"

The size of the box may need to increase to accommodate the additional text.

Daniel Wilson  Mar 14, 2021