Errata

Head First C#

Errata for Head First C#, Fifth Edition

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
Page Pg. 205 (.pdf) (Pg. 520 Kindle eBook version)
Paragraph before "There are no Dumb Questions" section

The text in the last paragraph before the "there are no Dumb Questions" section does not match what is being discussed directly above and the code snippet uses as an example. As there is no "ScoreText.text" within the snippet or an attempt to assign 'x' to it.

This can be found in Chapter 4 page 205 of the .pdf file. It is the same in my Kindle eBook version on page 520 (page may differ slightly based on font size on Kindle).

I would copy and paste the exact text involved, but there is an image (Error Exception message) within the text that interferes.

Note from the Author or Editor:
Thanks for catching this – looks like this was a (ScoreText.text is from a Unity lab later in the book). This paragraph should be updated to read:

text is a string variable, so when you used the + operator to concatenate a string it converted the value to a string and the assignment worked. But when you try to assign the number value to it directly, it doesn’t have a way to automatically convert the long value to a string. You can convert a numeric value (or any other value!) to a string by calling its ToString method.

David Fournier  Oct 01, 2024 
Printed, PDF, ePub, Mobi, O'Reilly learning platform, Other Digital Version
Page Pages 646 and 652

On page 646:


Add a caption box (one of those boxes with rounded corners and Arial Rounded Bold text) to the upper corner of the page (the word "Composition" should be in gray):

Composition is a design principle where a class is built using objects of other classes as its parts. It's like creating a complex machine using simpler, reusable components. This approach allows for flexible and modular code structure, making it easier to change or extend functionality without affecting the entire system.


In the text under the bottom object circle graphic, change "List<Passengers> object" to "List<Passenger> object" (remove the "s" from Passengers).


Add a caption box to the lower right corner inside the "Brain power":

This is a good example of composition: the Car class depends on the Engine, Tire, and Passenger classes to provide part of its behavior. How would you save the state of several classes that use composition to work together?




On page 652, add the following bullets to the Bullet Points box ("Composition" and "serializing composed objects" are in boldface):

* Composition means building objects using other objects as their parts. The behavior of a composed object comes from how its parts work together.

* When serializing composed objects, the entire graph of connected objects is saved, so all parts can be deserialized together.

Andrew Stellman
Andrew Stellman
 
Oct 21, 2024 
Page page 102
In the second Label under the Slider, SemanticProperties.Description

The second Label under the Slider element has a SemanticProperties.Description that reads "Here's the stepper value". It should read "Here's the slider value"

Note from the Author or Editor:
There are two occurrences of the following line on the page:

SemanticProperties.Description="Here's the stepper value" />

Change the SECOND one to:

SemanticProperties.Description="Here's the slider value" />

onyx  Sep 01, 2024 
Page Pg. 99, Step 4
Top of page.

There is no “Margin” property in the Properties window. Had to type Margin="0,0,0,20" into the tag by hand.

Note from the Author or Editor:
Add a warning to the top of the page formatted similar to the on at the top of page 30 (you can remove the line break between the first two paragraphs to make room):

An update to Visual Studio since we took that screenshot may have removed Margin from the Properties window. If you don't see it (or any other property), just type the XAML so it matches.

David Templeton  Sep 04, 2024 
Page 10
1st paragraph

“Try moving the panels in Visual Studio around. Click the pushpin button ( ) to collapse
the Solution Explorer window into the side panel. Reset the layout by choosing Reset
Window Layout from the View menu, then choosing Output from the View menu.”
“Reset Window Layout” is in the Window menu, not View. I have no idea what choosing “Output” from the View menu accomplished.

Note from the Author or Editor:
In the heavy text at the the top of the page, change this:

Reset the layout by choosing Reset Window Layout from the View menu, then choosing Output from the View menu.

to this:

Reset the layout by choosing Reset Window Layout from the Window menu, then use the View menu to open other windows.

David Templeton  Aug 28, 2024 
Page 29
"Step 2", top of page

Step 2.
“Your C# code should now look like this:” is wrong.
There should be an open curly bracket under the n in namespace, the “public partial class” block should be indented, then a closed curly bracket under the first added bracket, at the end of the namespace block.

Note from the Author or Editor:
Change the code in step 2 at the top of page 10 to this:

namespace AnimalMatchingGame
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
}

David Templeton  Aug 28, 2024 
Printed, PDF, ePub, Mobi, O'Reilly learning platform, Other Digital Version
Page 54
Add new caption box to the bottom of the page

Add the a caption box (one of those boxes with rounded corners) to the bottom of the page with the following text – you can move the "Sharpen your pencil solution" box up to make room:

Do you see a warning in the Error List window about a non-nullable field? Your code will still run even when you see green warnings (unlike errors red errors, which mean your code can't run). But you should still pay attention to warnings! Don't worry about this warning for now—you'll learn about what it is and how to fix it in Chapter 11.

Andrew Stellman
Andrew Stellman
 
Sep 26, 2024 
Page 83
Method declarations in the code

The keyword "static" is unnecessary and should be removed.

Note from the Author or Editor:
Remove the word "static" from these lines:

static void TryAnIf()

static void TryAnIfElse()

static void TrySomeLoops()

Andrew Stellman (author)  Aug 31, 2024 
Printed, PDF, ePub, Mobi, O'Reilly learning platform, Other Digital Version
Page 140
Bullet #3

Bullet #3 has says "foreach loop" in both the bullet ("Add a foreach loop to set the value" and the second sentence of the body ("Add this foreach loop—").

Both instances of the word "foreach" should be replaced with "for" – the reader adds a for loop, not a foreach loop.

Andrew Stellman
Andrew Stellman
 
Oct 04, 2024 
Printed, PDF, ePub, Mobi, O'Reilly learning platform, Other Digital Version
Page 141
Code at bottom of page

The code at the bottom of the page has the following comment:

// otherwise return the string

This comment got cut off. It should be:

// otherwise return the string Diamonds

Andrew Stellman
Andrew Stellman
 
Oct 04, 2024 
Printed, PDF, ePub, Mobi, O'Reilly learning platform, Other Digital Version
Page 147
Game Design... and Beyond box

In the boldfaced text "rapidly experiment with a lot of different ideas" the 'r' 'rapidly' is bold italic. It should just be italic.

Andrew Stellman
Andrew Stellman
 
Sep 26, 2024 
Page 154
First paragraph, second setence.

Currently reads: 'Now it’s time to take reuse that class by copying the file'. Possible change: 'Now it's time to reuse that class'

Note from the Author or Editor:
Change: "Now it’s time to take reuse that class by copying the file"

To: "Now it's time to reuse that class by copying the file"

(remove the extra word "take")

onyx  Sep 01, 2024 
Printed, PDF, ePub, Mobi, O'Reilly learning platform, Other Digital Version
Page 156
Exercise Solution and Bullet Points

Remove the following annotation (including the arrow) from the Exercise Solution box:

What happens if you don’t add this last line to your PickedCards label? Does it look weird? Can you sleuth out how to fix it?


Remove the extra word "is" in the following bullet in the Bullet Points:

The global namespace is contains the top-level statements and any class not explicitly put into a namespace using a namespace declaration.

Andrew Stellman
Andrew Stellman
 
Sep 26, 2024 
Page 165, 160, 188
Mentions of "new Random()"

These pages reference the following statement from code earlier in the book:

static Random random = new Random();

That statement was removed in the 5th edition.

Note from the Author or Editor:
On page 160:

Remove the graphic of Nina sitting in a chair, the thought bubble, and the learner answer "Yes! You've already created instances in your own code." and the text and code underneath it.




On page 165:

Remove the following text:

You’ve seen how classes can contain fields as well as methods. We just saw how you used the static keyword to declare a field in your CardPicker class:
static Random random = new Random();
What happens if you take away that static keyword? Then the field becomes an instance field, and every time you instantiate the class, the
new instance that was created gets its own copy of that field.

and replace it with the following (put the word "field" in boldface):

We just saw an example of a House class that's used to instantiate House objects. Each house needs to remember its address: the 38 Pine Street instance of House needs to store its specific address, while the 115 Oak Drive instance needs to remember a different one.

This is where fields come in—they store the data that each instance of the class needs to keep track of. Every time you instantiate the class, the new instance that was created gets its own copy of that field.




On page 188, remove the following bullet point:

When you included new Random(); in your code, you were creating an instance of the Random class.

Andrew Stellman (author)  Aug 31, 2024 
Page 184
Third line of exercise solution, unnecessary assignment to random variable

Unnecessary assignment to variable random. (We call Random.Shared.NextDouble())

Note from the Author or Editor:
Remove this line of code:

Random random = new Random();

onyx  Sep 01, 2024 
Page 236
First Instruction step (not sure of location as I have the Kindle eBook version)

In the Fifth Edition of your book there is a breakpoint positioning error in Chapter 2 on page 236 (I hope you can locate it by referring to the exact text).

In the first instruction is to: "Click on the line just above the first loop and choose Toggle Breakpoint (F9) from the Debug menu to add a breakpoint"

This appears to be an error as the IDE for Visual Studio 2022 Comm. does not allow you to place a breakpoint on a blank line.

Note from the Author or Editor:
Change the text: "Click on the line just above the first loop"

to: "Click on the line of code just above the first loop"

David Fournier  Sep 19, 2024 
Page 375
First sentence

Typo Beehive Nanagement System.

Note from the Author or Editor:
Change "Nanagement" to "Management"

onyx  Sep 01, 2024 
Page 561
Under subheading LINQ queries are built from clauses, first sentence

Currently reads: 'Let’s build a query that finds the numbers in an int array that are under 37 and puts those numbers in ascending order.'

However, the LINQ query presented sorts the numbers in descending order.

Note from the Author or Editor:
Change: "and puts those numbers in ascending order."
To: "and puts those numbers in descending order."

onyx  Sep 01, 2024 
Page 723
Top of page, handwritten question.

This needs checking but the question at the top of the page:

'Remember the sealed modifier from Chapter 7? It’s how you set up a class that can’t be extended.'

Refers to the sealed modifier from chapter 7, but I don't think the sealed modifier had been mentioned by that point. I may be mistaken though.

Note from the Author or Editor:
This is correct. Make the following changes.

Page 699:

Remove the annotation "Structs can implement interfaces but can't subclass other classes. And structs are sealed so they can't be extended."

Replace it with a caption box (one of those boxes with rounded corners) with the following text:

Structs can implement interfaces but can't subclass other classes. And structs are sealed so they can't be extended. You can make any class sealed by adding the sealed access modifier to it.

Add Access modifiers, sealed to the index


Page 723:
Change this annotation: "Remember the sealed modifier from chapter 7? It's how you set up a class that can't be extended."

To this: "We talked about earlier in the chapter about how structs are sealed, and how you can use the sealed access modifier to make a class that can't be extended."

onyx  Sep 01, 2024