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.

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
Printed Page Chapter 1 pg. 8 and Errata Sheet - 1st item for pg. 8
2nd sentence in chapter 1. page 8

Errata for pg. 8 is WRONG. It says to replace select WPF App (.NET Core) with
select WPF App (.NET)

THERE IS NO WPF App (.NET) template.

I have VS 2019 installed on two machines .... and NEITHER one has that template.

What both machines have listed are these two templates :

WPF Application
and
WPF App (.NET Framework)

So which one of these to choose ???

( FYI— I chose the latter one....)

There are many other errors in Chapter 1 and I will enumerate them in separate submissions.

Massey Ferguson  Dec 03, 2022 
PDF Page MVVM chapter page 22
StopwatchView() constructor

When I coded the console version of the stopwatch, sometimes the elapsed time printed several times when the watch was started. This also happens when I run the downloaded solution, the text below is from the first stopwatch solution, without the pause feature.

00:00:07.400:00:00.700:00:00.700:00:00.700:00:00.600:00:00.600:00:00.6

This happens intermittently, and I had to run the author's solution a few times before it presented.

When I tried stepping through StopwatchView.WriteCurrentTime(), execution did not proceed to the next line as expected, it sometimes jumped up a line or two, or executed the same line repeatedly. Did some research, and a post at stackoverflow provided the solution: it has to do with the timer running in a different thread from the view.

The solution offered, which seems to work for me, is to start the watch with an infinite period, so it executes only once:

_timer = new Timer(timerCallback, null, 0, Timeout.Infinite);

The change it in UpdateTimeCallback(), the callback method, *after* the writes to the console. When changed, the period is set to infinite again:

_timer.Change(10, Timeout.Infinite);

Mike Palandri  Dec 12, 2022 
Printed, PDF, Other Digital Version Page page 441
right before point 4

Which makes sense—it’s exactly like safely upcasting versus downcasting, which you learned about in
Chapter 6: we can use assignment to downcast, but we need to use the is keyword to safely upcast. So how do we safely upcast our List<Duck> to a List<Bird>?

The line "we can use assignment to downcast, but we need to use the is keyword to safely upcast".
Isn't it the other way around? We can use assignment to upcast, but we need to use the is keyword to safely downcast.

Alexander  Dec 29, 2022 
Printed, PDF Page 75 - 78
"Mini Exercise", bottom of p.75 through "Sleuth it out", p.78.

If the directions on pp. 75 and 76 are followed EXACTLY, and the program is run, there is no exception thrown. This is because when the TextBlock is added to the grid in the "Mini Exercise" at the bottom of p. 75, it will appear first in the list of tags, right below the tag for the Label. The TextBox is added next, top of p. 76, Step 4, and appears BELOW the tag for the TextBlock. This is NOT what is shown at the bottom of the page, but what is the “fix” described in the “Sleuth it out” box on p. 78.
If the instructions for adding the tools to the grid are followed correctly, when the program is run the exception will not appear. This completely alleviates the exception issue that is dealt with on pp. 77 and 78.

Dave Templeton  Sep 29, 2023 
Printed Page 81
Middle

It's impossible to add ListBoxItems from the Properties/Collection Editor menu without VS throwing an exception. You need to enter each ListBoxItem manually in the XAML editor, or else, it simply won't work.

Daniel Pilon  Jul 20, 2022 
PDF Page 271
15. The four whole-number types that only hold positive numbers

isn't
"15. The four whole-number types that only hold positive numbers"
just
"15. The whole-number types that only hold positive numbers" or "15. The four byte of whole-number types that only hold positive numbers"?

Kenial Lee  Jul 24, 2022 
PDF Page 271
15. The four whole-number types that only hold positive numbers

isn't
"15. The four whole-number types that only hold positive numbers"
just
"15. The whole-number types that only hold positive numbers" or "15. The four byte of whole-number types that only hold positive numbers"?

Kenial Lee  Jul 24, 2022 
PDF Page 302
bottom part

"new public void ReturnContents(Jewels safeContents, Owner owner)" should be "new protected void ReturnContents(string safeContents, SafeOwner owner)" to be matched to the explanation.

Kenial Lee  Jul 24, 2022 
PDF Page 439
2nd paragraph

The book says: when an object implements the IEnumerable<T> interface,
the specific job it does is that it supports iteration over a nongeneric
collection.
In my opinion, there is <T> after IEnumberable, why do you say supports nongeneric collection? Thanks

littlefox  Nov 02, 2022 
PDF Page 452
Optional Downloadable Project for Chapter 8: TwoDecksWPF

The instructions of the optional PDF project in chapter 8 followed to a T lead to "The resource "rightDeck" has an incompatible type" error. Neither "rightDeck" nor "leftDeck" can be selected as an itemsource through the instructions laid out.

The downloaded solution is also uncompilable and has the same errors.

Daniel Figueroa  Apr 08, 2022 
Printed Page 505
var expectedResults = new[] { ... }

Because of local formatting my unit test were failing with error: CollectionAssert.AreEqual failed. (Element at index 0 does not match.)

I had to replace the . (dot) to a , (comma) in the expectedResults variable.

Luckily i found the error with the debug option of the test explorer.

For me the unit tests passed with below as my new expectedResults variable.
I think this only applies to systems/countries that use a comma as a decimal separator.

var expectedResults = new[]
{
"MuddyCritic rated #1 'Issue 1' 14,50",
"RottenTornadoes rated #1 'Issue 1' 59,93",
"MuddyCritic rated #2 'Issue 2' 40,30",
"RottenTornadoes rated #2 'Issue 2' 95,11",
};

Marco Ponne  Jul 14, 2023 
PDF Page 545-546
All code with tests on these pages. Returns the error CollectionAssert.AreEqual failed. (Element at index 0 does not match.)

Errors appear when finish the test: CollectionAssert.AreEqual failed. (Element at index 0 does not match.) Downloaded versions of the code from GitHub give the same errors

Denys Turovskyi  Nov 05, 2022 
PDF Page 576
Downloadable Exercise

This is on Page 8 of the Downloadable Hide and Seek exercise from chapter 10. After adding all of the rooms to the Test Initialize Method, the Assert should show a Count of 12, not 10.

Jim Cupec  Apr 18, 2021 
PDF Page 576
p12 of the Hide and Seek Exercise

To parse the input in the GameController, the instructions tell you to use a TryParse method as shown in Chapter nine. I can't find it anywhere in Chapter nine. There is an oblique reference on page 607 of Chapter 11, but it says it doesn't work for enums which I find misleading. I spent some time in microsoft docs finding enum.TryParse and Enum.IsDefined. The instructions need to be corrected and a better definition or example of TryParse would be a great addition to the book.

Jim Cupec  Apr 19, 2021 
Printed Page 603
last paragraph

In the method
public SpeakThreeTimes(Dog dog)
{
int i;
for(i= 0, i < 5, i++)
dog.Speak();
}
it should be i < 3. Otherwise the dog will speak 5 times, not three.

Anonymous  Aug 30, 2023 
Printed Page 708
Step 1

When I replacing the Index.razor page, the first line to replace is the @page "/" .
When I replace the code the "@page "/" shows as text in the browser.

Terry Conner  Nov 18, 2022