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
Page 277
bullet 5

Bullet 5 has a missing illustration that is labeled "Here's what it'll look like:" Please add the image, which is important to see right there.

Doug Hilton  Dec 22, 2011  Nov 18, 2011
Printed, PDF
Page 154
2nd method example

In the "SpeakTo" method there is a call to the "TellMe" method. Off to the sde there is a not that says, "This method in the Elephant class calls another elephant's TalkTo() method. It lets one elephant communicate with another one."

I'm assuming the "TalkTo()" method is really referring to the "whoToTalkTo()" method. If not, I can not find what other "TalkTo()" method that is being discussed.

Note from the Author or Editor:
In the annotation, change "TalkTo() method" to "TellMe() method"

Randy Naviaux  Nov 26, 2011  Oct 26, 2012
182
Bottom Annotation

Change labelCost to costLabel in the bottom annotation.

Jennifer Greene
Jennifer Greene
 
Nov 15, 2011  Nov 18, 2011
Printed
Page 88
Bottom of page

The 2 examples the notes point to at the bottom of the page are missing completely.

Nick Jordan  Nov 14, 2011  Nov 18, 2011
PDF
Page 736
class Guy field declarations

The XML summary comment for the "private readonly int age;" declaration should read:

/// <summary>
Read-only backing field for the Age property
/// </summary>

Note from the Author or Editor:
In the comment on the second line of this code block:

/// <summary>
/// Read-only backing field for the Name property
/// </summary>
private readonly int age;

Change "Name" to "Age"

PolygonUK  Nov 11, 2011  Nov 18, 2011
PDF
Page 117
Steps 5

There is two Step 5, last one should be step 6.

Note from the Author or Editor:
Change the last step number from (5) to (6)

Anonymous  Nov 08, 2011  Nov 18, 2011
PDF
Page 48
middle of the page

There's two #2 step.

Note from the Author or Editor:
Change the third bullet from (2) to (3)

Anonymous  Oct 30, 2011  Nov 18, 2011
Printed
Page 85
United States

Second sentence of last paragraph says: "That's why are really useful."

Perhaps you meant to say, "That's why they are really useful."

Note from the Author or Editor:
Insert the word "objects" and make it boldface into that sentence: That's why objects are really useful.

Jared Roper  Oct 27, 2011  Nov 18, 2011
Printed
Page 88
End of first paragraph

The last sentence in the first paragraph reads: "That's why Mike stuck them together into one class, and called that class ."

It should read: "That's why Mike stuck them together into one class, and called that class Navigator."

Note from the Author or Editor:
Change the sentence to

"That's why Mike stuck them together into one class, and called that class Navigator."

Jared Roper  Oct 27, 2011  Nov 18, 2011
PDF
Page 337-338
In the table for the exercise

The seventh line of code on the List side of the table on pg. 337 reads:

Guy o = myList[1];

but the instructions for the Exercise state, "Assume these statements are all executed in order, one after another." The plain understanding of this notation is that the List object myList referenced here is the same as the List object declared at the start of the exercise:

List<String> myList = new List <String>();

The problem here is the Guy is not String, so this assignment does not work, it doesn't get any better when the reader is expected to create a version of this statement for an array (also of type String). The statement should read:

String o = myList[1];

This is all repeated in the Exercise Solution on pg. 338.

Note from the Author or Editor:
Change the three occurrences of "Guy o = myList[1];" on pages 337 and 388 to: Guy o = guys[1];

James West  Oct 22, 2011  Nov 18, 2011
Printed
Page 92
Bottom of the page

All the example code in the box at the bottom of the page is missing. Everything around the box including graphic annotations is there but the code is missing. Here is a link to a picture: http://s916.photobucket.com/albums/ad8/atyannikov/?action=view&current=photo1.jpg

Thanks

Anonymous  Oct 21, 2011  Nov 18, 2011
Printed
Page 88
Bottom of pate

Under the section "Some methods have a return value", two side notes point to what are supposed to be code examples but the areas of the page being pointed to are blank.

E Larson  Oct 18, 2011  Nov 18, 2011
Printed
Page 494
Bottom of the page, left and right annotations

doRisky() should be changed to DoRisky()

Note from the Author or Editor:
In the lower left-hand annotation, change doRisky() to DoRisky()

Rick Costello  Oct 07, 2011  Nov 18, 2011
PDF
Page 88
Example Navigator class

After the first method declaration, all method declarations have a semicolon after the curly braces:

class Navigator
{
public void SetCurrentLocation(string locationName) { ... }
public void SetDestination(string destinationName) { ... };
public void ModifyRouteToAvoid(string streetName) { ... };
public string GetRoute() { ... };
}

All of these semicolons are syntax errors.

Note from the Author or Editor:
Remove the three semicolons from the ends of those three lines

James West  Sep 17, 2011  Nov 18, 2011
Printed
Page 204
Step 3

First sentence, "Here's the form for the code" should read "Here's the code for the form" since step 2 instructed you to build the form and step 3 provides the code to apply to the form.

Note from the Author or Editor:
Change "Here's the form for the code." to "Here's the code for the form."

mnmmusicman  Aug 11, 2011  Nov 18, 2011
Printed
Page 80
Snippet

The solution for the Pool Puzzle shows the Snippet of Poem = Poem + "a"; without a space but on the pg 80 the snippet shows the Poem = Poem + "a "; with a space. The solution is correct without the space. Not sure if it will affect the alternative solution.

Note from the Author or Editor:
In the pool at the bottom of the page, in this line: Poem = Poem + ?a ?;

remove the extra space after "a"

Powiee  Jul 14, 2011  Nov 18, 2011
PDF
Page 376
bottom

In Player.AskForACard() method there must be a check for "stock.Count > 0" like this:

if (totalCardsGiven == 0 && stock.Count > 0) {
textBoxOnForm.Text += Name + " had to draw from the stock" + Environment.NewLine;
cards.Add(stock.Deal());
}

Note from the Author or Editor:
In the fourth line of code from the bottom, change this:
if (totalCardsGiven == 0) {
to this:
if (totalCardsGiven == 0 && stock.Count > 0) {

Anonymous  Jul 07, 2011  Nov 18, 2011
Printed
Page 491
Note at top right of page

Note currently reads: Of course, one method in a single class can throw a method that's caught by another method in the same class.

It should read: Of course, one method in a single class can throw an exception that's caught by another method in the same class.

Note from the Author or Editor:
In the upper right-hand annotation, change "throw a method" to "throw an exception"

Justin Jenkins  Jun 21, 2011  Nov 18, 2011
Printed
Page 428
Second using statement under 'Use multiple using statements for multiple objects'

The second using statement should read:

using (StreamWriter writer = new StreamWriter("email.txt"))

In the printed version it reads:

using (StreamWriter writer = new StreamReader("email.txt"))

Note from the Author or Editor:
In the bottom block of code, change this: StreamReader(?email.txt?)
to this: StreamWriter(?email.txt?)

Justin Jenkins  Jun 02, 2011  Nov 18, 2011
Printed
Page 289
Step 3, first bullet point, final sentence

The text says "The FunnyThingIHave set accessor should return the same thing.". Shouldn't this refer to the "get" accessor? Similarly, the first hand-written note in the Exercise Solution on page 290.

Note from the Author or Editor:
In the last line of the first paragraph under (3) on 289, change "set accessor" to "get accessor". Also, make the same change to the third line of the top annotation of page 290.

Colin  May 16, 2011  Nov 18, 2011
Printed, PDF, , Other Digital Version
Page 356
The class diagram

The boxes and lines in the class diagram are dashed -- they should be solid.

Anonymous  May 13, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 690
First annotation on the right-hand side of the page

Under the top annotation there's an underline that's shifted too far to the right. It should be under the words "range variable".

Anonymous  May 13, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 496
Toward the middle of the right-side of the page

Something looks weird with the font in the box in the middle of the page. I think it has an extra 1pt black stroke around it or it might be bold? It should look similar to the box on page 184.

Anonymous  May 13, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 315
Similar to the problem on p309


Similar to the problem on p309, except the text should say:
Let's get started!

Anonymous  May 13, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 309
At the bottom of the page

There's an arrow that should be pointing to text in the font "Couchlover" saying:

"We're not done yet--flip the page!"

(just like on p313)

Anonymous  May 13, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 183
In step #7

There's a line through the code "(int)" -- this should be an underscore

Anonymous  May 13, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 144
The top annotation is missing (there's an arrow with no annotation).


It should read:
Rover is a Dog object with a Breed field set to "Greyhound".

Anonymous  May 13, 2011  May 20, 2011
PDF
Page 299
Last part

In the subclass Venus, the method declaration is incorrect. It does not have a return type.

The return type should be void:

public override void SetMissionInfo(....



Note from the Author or Editor:
In the bottom code block, change "public override SetMissionInfo" to "public override void SetMissionInfo"

Anonymous  May 06, 2011  Nov 18, 2011
Printed
Page 335
Middle of page (item #2, adding to a list)

I think you're missing an extra closing parenthesis on each of the three "cards.Add" lines.

Note from the Author or Editor:
In step #2, add extra closing parentheses before the semicolons, so each line ends with ));

Maggie  Apr 21, 2011  Nov 18, 2011
PDF
Page viii
Right column (Jenny) - 2nd paragraph - 2nd line - 2nd word

word has 2 "L"s, i.e. "quallity", but should only have 1.

Note from the Author or Editor:
This is the most ironic errata so far. Please change the word "quallity" to "quality".

John Sullivan  Apr 08, 2011  Nov 18, 2011
Printed
Page 400
Top

The constructor for a "Weapon" (which descends from "Mover") doesn't call its parent's constructor. Instead, it holds it's OWN copy of both the reference to a "Game" and the location property -- both of which are fields in its parent class.

When entered as it appears in the book, Visual Studio highlights the "Weapon" constructor and complains about class "Mover" not containing a constructor that accepts 0 parameters.

Unless I'm very wrong, I would replace:

protected Game game;
private bool pickedUp;
public bool PickedUp { get { return pickedUp; } }
private Point location;
public Point Location { get { return location; } }

public Weapon(Game game, Point location) {
this.game = game;
this.location = location;
pickedUp = false;
}

with:

private bool pickedUp;
public bool PickedUp { get { return pickedUp; } }

public Weapon(Game game, Point location)
: base(game, location)
{
pickedUp = false;
}

which is how the constructor for class "Enemy" (which also inherits from "Mover") works.

Thank you for providing me with such an invigorating, stimulating and entertaining way to learn C# -- I've convinced the institution where I am taking my degree to use your book from now on :) It's brilliant!

Note from the Author or Editor:
1. Replace this block of code:
protected Game game;
private bool pickedUp;
public bool PickedUp { get { return pickedUp; } }
private Point location;
public Point Location { get { return location; } }
with this:
private bool pickedUp;
public bool PickedUp { get { return pickedUp; } }


2. Remove this annotation: "Every weapon has a location in the game dungeon."


3. Replace this block of code:
public Weapon(Game game, Point location) {
this.game = game;
this.location = location;
pickedUp = false;
}

with this:

public Weapon(Game game, Point location)
: base(game, location)
{
pickedUp = false;
}


4. Replace this annotation: "The constructor sets the game and location fields, and sets pickedUp to false (because it hasn?t been picked up yet)."
With this: "The constructor calls the Mover base constructor (which sets the game and location fields), and then sets pickedUp to false (because it hasn?t been picked up yet)."

Alex McMillan  Mar 01, 2011  Nov 18, 2011
Printed
Page 641
Code in step 6

2nd Edition:

The call to the DrawString methods should pass font as a parameter instead of Font to use the local variable.

Current text:
e.Graphics.DrawString("First page", Font, Brushes.Black, 0, 0);
and
e.Graphics.DrawString("Second page", Font, Brushes.Black, 0, 0);

Should be:
e.Graphics.DrawString("First page", font, Brushes.Black, 0, 0);
and
e.Graphics.DrawString("Second page", font, Brushes.Black, 0, 0);

also, the initial position of either the bee or the text should be moved so they don't overlap on the page. Currently they both have their origin set to 0,0.

Note from the Author or Editor:
Change the two lines of code as specified (replace "Font" with "font").

Cinco13  Mar 01, 2011  Nov 18, 2011
Printed, PDF, , Other Digital Version
Page 400
Bottom left annotation (the one that starts with "The Nearby() method...")

Add this sentence to the end of the bottom left hand-written annotation (the one that starts with "The Nearby() method..."):
You'll also need to add a similar overload for the Move() method.

Andrew Stellman
Andrew Stellman
 
Feb 17, 2011  May 20, 2011
Printed, PDF, , Other Digital Version
Page 449
First paragraph

Change this text: So add another button to your program, and we'll show you how to use BinaryWriter() .
To this: So let's create a new Console application that uses BinaryWriter to write binary data to a file.
(Make sure that the word BinaryWriter is in Courier New font.)

Andrew Stellman
Andrew Stellman
 
Feb 17, 2011  May 20, 2011
Printed
Page 195
Statement #3

Figure after equals sign should be 54, not 94.

Note from the Author or Editor:
Change 94 to 54

Maggie  Feb 16, 2011  Nov 18, 2011
Printed
Page 527
2nd Edition: annotation on HiThere() method

Annotation reads "This method's signature matches ReturnsAString."

Should be "This method's signature matches ConvertsIntToString." to match the delegate name.

Note from the Author or Editor:
In the third annotation from the bottom, changes ReturnsAString to ConvertsIntToString

Cinco13  Feb 14, 2011  Nov 18, 2011
Printed
Page 141
First line

Replace "a container" with "containers".

Maggie  Feb 10, 2011  Nov 18, 2011
Printed
Page 134
Bottom of exercise

There should be 2 more lines at the bottom of the exercise table for the "while" definition.

Note from the Author or Editor:
Add two more rows to the bottom of the table so the reader can write in them.

Maggie  Feb 10, 2011  Nov 18, 2011
Printed
Page 131
Bottom left: note about "double" type

I don't understand floats and doubles. Specifically, I don't understand the line: double myFloat = 16.4D;

Why do you add a "D" to the end of the number? I would think you would add an "F" to indicate a float. Why are you telling the compiler it's a float and not a double, when it IS a double? If the only difference between float and double is that the double holds more decimal places, what difference does it make anyway? Why can't you just put in 16.4? What would happen if you did?

Note from the Author or Editor:
Change the second line of code in the block near the bottom of the page to "float myFloat = 16.4F;"

Change the annotation to: When you?re assigning a number value to a float, you need to add a F to the end of the number to tell the compiler that it?s a float, and not a double. Otherwise, the code won't compile.

Maggie Jacobs  Feb 10, 2011  Nov 18, 2011
Printed
Page 299
Constructor of Venus class, bottom of the page

2nd edition

The method call in the constructor is misspelled.

Change "SetMissinInfo" to "SetMissionInfo".

Note from the Author or Editor:
Change SetMissinInfo to SetMissionInfo in the block of code at the bottom of the page

Cinco  Jan 27, 2011  Nov 18, 2011
Printed
Page 396
Error is in the Player Constructor about middle of the page

The book has this:

public Player(Game game, Point location); <--this semicolon not correct
: base(game, location) {
hitPoints = 10;
}


I believe this is correct:
public Player(Game game, Point location)
: base(game, location) {
hitPoints = 10;
}

Can you please let me know if this is an error or if I just got this wrong?

Thanks!

MB

Note from the Author or Editor:
Remove the semicolon from the end of this line: public Player(Game game, Point location);

Mark Berry  Jan 25, 2011  Nov 18, 2011
Printed
Page 339
In code

"Typo" #1
The code says:

Shoe thirdShoe = shoeCloset[3];
Shoe secondShoe = shoeCloset[2];

This is a bit misleading, as the shoeCloset index numbers start at zero, not one. Thus, the two Shoe variables actually contain the 4th and 3rd list elements.

Typo #2
The note at the bottom of the page reads:

"We only added thirdShoe into the cleared list, not fifthShoe"

As there is no fifthShoe variable, I believe they should have said "secondShoe".

Note from the Author or Editor:
Change the [3] and [2] to [2] and [1] in the first two lines in the second to last block of code on the page, so they look like this:
Shoe thirdShoe = shoeCloset[2];
Shoe secondShoe = shoeCloset[1];

In the annotation at the bottom of the page, change fifthShoe to secondShoe

Anonymous  Jan 21, 2011  Nov 18, 2011
PDF
Page 173
3rd line of code

The comment in line 3 says: // An instance of Bet() that has his bet

Bet() is the constructor, not the class. That's why it should be Bet.

Note from the Author or Editor:
In the third line of code on the page, change "An instance of Bet() that has his bet" to "An instance of Bet that has his bet"

Henrik Wall  Jan 17, 2011  Nov 18, 2011
PDF
Page 64
On the right

The text reads: You can pin it so it says open

We should probably read: You can pin it so it stays open

Note from the Author or Editor:
In the annotation, change "says open" to "stays open"

Anonymous  Jan 13, 2011  Nov 18, 2011
Printed, PDF, , Other Digital Version
Page 365
Bottom of page

In the third line of code from the bottom, remove "as JerseyNumber" from the end. So it should look like this:

JerseyNumber jerseyNumber = retiredNumbers[(int)number.SelectedItem];

Andrew Stellman
Andrew Stellman
 
Jan 09, 2011  May 20, 2011
Printed
Page 82
4th line in the solution

You have an extra curly bracket. Either remove it from the "code magnet" on the while loop and the answer is correct or remove the extra curly bracket you have them write in after the while line. You'll probably also have to modify page 74 since if you remove it from the while the magnet changes, but if you keep it and change adding the extra curly bracket the text says to "add a couple" and this would be confusing.

Note from the Author or Editor:
On pages 74 and 82, remove the { from the "while (x > 0) {" magnet

Mike  Jan 05, 2011  Nov 18, 2011
PDF
Page 203
United States

I could be wrong but

"Even though the code treats NumberOfCows like
a field, it runs the set accessor, passing it 20.
And when it queries the BagsOfFeed field it runs
the get accessor, which returns 300"


I believe that is wrong.. because in the set accessor 20 is the number of cows and 30 is the multiplier. So running the BagsOfFeed property after will return 600. Also I am not sure why you call BagsOfFeed a field since it is a property since you are using Pascal case and talking about it's get accessor (even though we don't see the code for it).

Note from the Author or Editor:
In the bottom line of the annotation on the bottom of the page, replace "which returns 300." with "which returns 20 * 30 = 600."

joseph  Nov 15, 2010  Nov 18, 2011
Printed, PDF, , Other Digital Version
Page 673
3/4 of the way down, after the fourth block of code

After the fourth block of code ("myDate = (DateTime) myNullableDate;") add the following line of body text, followed by another indented block code (which should be in the same large bold Courier font as the second block of code earlier on the page):

[Body text]
But you also get this handy Value property--it also returns the value:

[Indented block of code, in larger bold Courier font]
myDate = myNullableDate.Value;

To make room for this addition, reduce line spacing for the second block of code ("bool? myNulableInt = null; ... DateTime? myNullableDate = null;"). If that doesn't give you enough space, you can remove the line break in the body text in between "that returns true if it's not null." and "You can always convert a value type to a nullable type:".

Andrew Stellman
Andrew Stellman
 
Nov 13, 2010  May 20, 2011
Safari frame
Table of contents

The table of contents in Safari has an outline problem. The first four chapters look fine, but then lab #1 (which is just another chapter) is labeled "Pt. 1", and you need to click on it to expand it to see chapters 5, 6, 7, and 8. Lab #2 is labeled "Pt. 2" has chapters 9 through 15 under it, and Lab #3 is labeled "Pt. 3" with the appendix under it. These should all be on the same level, with no parts -- Lab #1, Lab #2, and Lab #3 should just be chapters, at the same outline level as the other chapters.

Andrew Stellman
Andrew Stellman
 
Nov 13, 2010  Oct 22, 2012
Printed, PDF, , Other Digital Version
Page 54
Bottom

Please add the following text at the bottom of the page 54 in Arial Black 10pt (or another font, if it looks better):

C# is case sensitive! Make sure your uppercase and lowercase letters match example code.

(The words "case sensitive" should be in 80% gray, the rest in 100% black.)

Andrew Stellman  Nov 01, 2010  May 20, 2011
Printed, PDF, , Other Digital Version
Page 763
Bottom annotation, third line

Change this text: type this query into its event handler
to this: type this query into the Main() method

Andrew Stellman  Oct 14, 2010  May 20, 2011
Printed, PDF,
Page 355
Upper right-hand corner annotation

Change the annotation in the upper right-hand corner of p355 to:
Collection initializers work with ANY IEnumerable<T> class --
as long as it also has a method called Add().

Andrew Stellman
Andrew Stellman
 
Sep 29, 2010  May 20, 2011
Printed, PDF,
Page 395
Lower right-hand corner

On page 395, add a box with Arial Rounded MT Bold 9pt text to the lower right-hand corner (make the word "switch" in the first sentence boldface).

This is a switch statement. It's a lot like an if/else statement, except instead of executing certain statements if a value is true or false, it compares a value against a bunch of different options. In this case, it checks the direction enum, and executes different statements based on its value. You'll learn more about switch statements in the next chapter. (Flip to page 435 for a sneak peak!)

Andrew Stellman
Andrew Stellman
 
Sep 28, 2010  May 20, 2011
Printed
Page 486
3rd paragraph on the left, 1 line before the last line.

"from that point on would be pretty different from you expected"
Should be:
"from that point on would be pretty different from WHAT you expected"

Cheers guys, very good book !

Jean-Fran?ois Turpin  Sep 08, 2010  May 20, 2011
PDF
Page 356
Top of page, first code block


You can't override this in the Penguin class definition:

public void Fly() {
Console.WriteLine("Flap, flap");
}

without marking Fly() as virtual first.

Note from the Author or Editor:
In the first box with Bird class code in it, change this line: public void Fly() {
to this: public virtual void Fly() {

And in the second box with Penguin class code in it, change this line: public void Fly() {
to this: public override void Fly() {

Uberedit  Sep 06, 2010  May 20, 2011
Printed
Page 330
Anotation in the middleand at the right of the page

The book says in an anonation:

"You can cast an int back to a trickScore. Since value is equal to 30, score gets set to TrickScore.Fetch. So when you call score.ToString(), it returns 'Fetch'".

But 30 is the value of TrickScore.Speak and not of TrickScore.Fetch.
I have compiled the program and it returns "Speak".

Thus, the anotation should be:

"You can cast an int back to a trickScore. Since value is equal to 30, score gets set to TrickScore.Speak. So when you call score.ToString(), it returns 'Speak'".

Thanks.

Note from the Author or Editor:
Submitter is correct -- make the change as specified.

Beliy Txuri  Aug 31, 2010  May 20, 2011
Printed
Page 310
At the top of page, step 6 of long exercise.

The book says:
"Here's the architecture for two of your objects, frontYard and diningRoom".
In my opinion, the two objects are "front Yard and livingRoom".
(diningRoom hasn't any door).

Thanks.

Note from the Author or Editor:
In the first sentence in the body text under #6, change the last word from diningRoom to livingRoom.

Beliy Txuri  Aug 30, 2010  May 20, 2011
Printed
Page 295
2nd. code line

In the second code line, a '{' is absent.
It must be:
"public void ShopTillYouDrop() {"
instead of
"public void ShopTillYouDrop()"

Thanks.

Note from the Author or Editor:
Add a { to the end of the second line of the code block, just like the submitter suggested:
public void ShopTillYouDrop() {

Beliy Txuri  Aug 30, 2010  May 20, 2011
Printed
Page 284
Sharpen your pencil Solution

Sorry, but my english is not good.

The answers to questions 1. and 2. must be:
1. 0, 3 and 6 (instead 0 and 6).
2. 0, 3 and 6.(instead 0 and 6).

(Bees[3] is INectarCollector) is true and the same for (Bees[3] is IStingPatrol).
Bees[3] is a NectarStinger object and consecuently, implements too the INectarCollector and the IStingPatrol interfaces.
I compiled the example and the results is 0, 3, 6.

Thanks you for this interesting book.

Note from the Author or Editor:
The submitter is correct -- the answers to both 1 and 2 should be "0, 3, and 6"

Beliy Txuri  Aug 30, 2010  May 20, 2011
Printed
Page 435
Text on right hand side, 3/4 of way up page (to the bottom right of the text that has the arrow at the top.)


Although the underscores are still there, the text is missing. It should say "A switch statement compares ONE variable against MULTIPLE possible values."

Anonymous  Jul 19, 2010  Sep 01, 2010
Printed
Page 172
In the upper right-hand corner


There's supposed to be a block of text, but it only has a few words. It looks like only the text that's in Courier managed to make it in; the text in Arial Rounded MT Bold got deleted. This isn't your fault. I've seen this before -- it's a bug in InDesign that causes all of the text in a text box in a certain font to disappear. Here's how to fix it.

It currently says: using System.Windows.Forms;using System.Drawing;public

It should say:

You'll need to add "using System.Windows.Forms;" to the top of the Greyhound and Guy classes. And you'll need to add "using System.Drawing;" to Greyhound (because the code on the bottom of this page uses Point, which is in that namespace). You'll also need to add the public keyword in front of each of your class declarations.

("using System.Windows.Forms;", "using System.Drawing;", and "public" are Courier, and the rest are Arial Rounded MT Bold)

Anonymous  Jul 19, 2010  Sep 01, 2010
Printed
Page 633
Multiple edits on page


- Add the word "method" (in body text font) after DrawImage(): Before
you call a Graphic object's DrawImage() method,
- Change using System.Drawing.2D; to be in Courier
- Center the text in the box


Add a box to the empty space on the bottom of page 633 (the box should look similar to the boxes on the bottom of page 745 or page 761):

Here's a quick tip to make your resized graphics look better. Before you call a Graphics object's DrawImage(), try setting its InterpolationMode property to InterpolationMode.HighQualityBicubic. (You'll need to add "using System.Drawing.2D;" to the top of your code.) You can learn more about how InterpolationMode works here: http://msdn.microsoft.com/en-us/library/k0fsyd4e.aspx

Anonymous  Jul 19, 2010  Sep 01, 2010
Printed
Page 25
In the line of body text under the screenshot that starts "Click the OK button",


Add one more sentence (including the parentheses):

(If you clicked OK earlier, you can open the Edit Table window again by right-clicking on the table in the Database Explorer and choosing "Edit Table Schema" from the menu.)

Anonymous  Jul 19, 2010  Sep 01, 2010
PDF
Page 514
Last sentence of the Watch It! box

The last sentence of the Watch It! box has two "the"'s in series: "...can become null between the the null check..."

Lars915  Jul 02, 2010  May 20, 2011
PDF
Page 308
Bold text under bullet 1

Bold text says "Create a Windows Application project...", should say "Create a Windows Forms Application project..."

Lars915  Jun 29, 2010  May 20, 2011
PDF
Page 310
Object diagram

The object diagram shows Backyard as an Outside object, it should be an OutsideWithDoor object to be consistent.

Note from the Author or Editor:
The text underneath the circle labeled BackYard should be changed from "Outside object" to "OutsideWithDoor object". (The easiest way to do this is probably to delete it, then copy the FrontYard circle, paste it, and change the label.)

Lars915  Jun 29, 2010  May 20, 2011
PDF
Page 308
Class diagram at top right of page

On page 308, the class diagram for Location shows Description() as a method, but on page 309, it is implemented as a property.

Note from the Author or Editor:
In the "Location" box, add the word "Description" above the line underneath the word "Exits". Then delete "Description()" from the bottom of the box, so nothing appears in the bottom of the box.

Larry Stein  Jun 29, 2010  May 20, 2011
PDF
Page 8
First paragraph

The wording in the first paragraph to set up the first project can be confusing. From my own experience first learning Visual Studio, I know that it can be easy to overlook the name field at the bottom of the screen. Changing this paragraph can help lessen that potential confusion.

Specifically: Remove the sentence "Name your project "Contacts" and click OK." Then in the next sentence, direct the reader to the bottom of the page to enter the project name.

Note from the Author or Editor:
In the first paragraph on page 8, add the following to the end of the last sentence:

by entering it in the "Name" box at the bottom of the "New Project" window.

(You may need to move the screenshot, Watch It! window, and everything else on the page down a little to make room.)

Lars915  Jun 17, 2010  Sep 01, 2010
Printed
Page 760
Bottom annotation

Add the following sentence to the bottom annotation on page 760:
You'll also need to use "Add Reference..." to add a reference to System.Runtime.Serialization for your project, just like you did in leftover #2.

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 754
First line of code in the middle of the page

There's a typo where "NameCollection()" should be changed to "NameEnumerator()" in the first line of code in the block in the middle of the page.

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 750 and 751
Bottom of p750 and a third the way down p751

There are two capitalization errors on p750 and p751 where "age" should be capitalized to "Age". The first is in the bottom line of code on p750 (other.Age == Age) and the second is in the second line of the GetHashCode() method on p751 (int result = Age;).

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 711
Fourth line of code from the bottom

Remove the { curly bracket from the end of this line of code: foreach (var row in results){

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 706
Last two paragraphs (above the box)

The bottom two paragraphs (starting with "After it's done") should be replaced with this to correct a typo (filenames should still be in Courier):

After it's done, your folder should contain a new file called ContactDB.dbml. Use "Add Existing Item" to add ContactDB.dbml to your project (again, select "Data Files" from the file type filter drop-down). When you add that file, the IDE automatically creates two more files: ContactDB.designer.cs, and ContactDB.dbml.layout.

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 665
Step #3 and step #4

In the first line of #3, change "button" to "Main() method": Add a Main() method that makes some copies of Dogs and Canines
Change the first line of #4 to: Before you run the program...

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 659
Last line of code on the page

In the last line of code on the page, ID is miscapitalized -- it should be Id (with a lowercase "d"): "Clone #" + Id + " says...");

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 630
Second line of code

In the second line of code, this text: new Bitmap("c:\..." is missing the @ before "c:\...."
It should look like this: Bitmap photo = new Bitmap(@"c:\Graphics\fluffy_dog.jpg");

Andrew Stellman
Andrew Stellman
 
May 30, 2010  Sep 01, 2010
Printed
Page 613
Third line of code at the top of the page

Remove "Bee." from this line of code: world = new World(new Bee.BeeMessage(SendMessage));
So it looks like this: world = new World(new BeeMessage(SendMessage));

Andrew Stellman
Andrew Stellman
 
May 29, 2010  Sep 01, 2010
Printed
Page 576
Top of the block of code

In p576 of the second edition, there's some unnecessary code at the top of the code block that should be replaced -- it does not affect the content of the chapter at all.

Replace the 13 lines of code starting with " // variable declarations" and ending just above the boldfaced code (the last line is a } on a line by itself) with the following:

// The existing code from the form remains unchanged.

Leave the boldfaced code (starting with "private void startSimulation_Click") unchanged.

Andrew Stellman
Andrew Stellman
 
May 29, 2010  Sep 01, 2010
Printed
Page 522
Text just above the screenshot

In the second edition on p522, there's a sentence missing from the paragraph just above the screenshot that starts "Now rebuild your code." Here's what that paragraph should look like:

You'll also need to change the OnBallInPlay method to replace EventHandler with EventHandler<BallEventArgs>. Now rebuild your code. You should see two errors in the Error List window:

(The text "EventHandler" and "EventHandler<BallEventArgs>" should be in Courier. There's room to move everything else on the page down to make room.)

Also, in the heading near the bottom of the page ("Use implicit
conversion...") there's a line above the word "new" -- this is an
underline, and it should be moved down below the word "new".

Andrew Stellman
Andrew Stellman
 
May 29, 2010  Sep 01, 2010
Printed
Page 493 and 494
One of the magnets

On pages 493 and 494, there's a magnet with the text "doRisky(test);" with a typo. The "d" should be uppercase: "DoRisky(test);"

Andrew Stellman
Andrew Stellman
 
May 28, 2010  Sep 01, 2010
Printed
Page 244
In the "Console applications don't use forms" box

In the box on p244 of the 2nd edition, replace this sentence:

You can read more about console applications in Appendix A.

with this (you may need to expand the box downwards for it to fit, but there's plenty of room):

You'll get a lot of practice using console applications over the next few chapters.

Andrew Stellman
Andrew Stellman
 
May 27, 2010  Sep 01, 2010
Printed
Page 356
Code in the middle of the page

(This is the author reporting errata.)

In the middle of the page, in this line of code:

List<Duck> ducks = new List<Duck>() { // initialize your list as usual }

Replace "// initialize your list as usual" with "/* initialize your list as usual */"

So the line should look like this:

List<Duck> ducks = new List<Duck>() { /* initialize your list as usual */ }

Andrew Stellman
Andrew Stellman
 
May 26, 2010  Sep 01, 2010
Printed
Page 154
Step #1, second line of code

(This is the author submitting errata.)

In the second edition, on page 154, in this line of code:

MessageBox.Show(whoSaidIt.Name + " says: " + message,);

There's an extra comma at the end of the line -- it should be:

MessageBox.Show(whoSaidIt.Name + " says: " + message);

Andrew Stellman
Andrew Stellman
 
May 26, 2010  Sep 01, 2010
Printed
Page 137
Step #2, second line of code

(This is the author submitting errata.)

In the second edition, on page 137 in step #2, in this line of code:

Messagebox.Show(milesTraveled + " miles", "Miles Traveled");

the "b" in should be uppercase in "MessageBox".

Andrew Stellman
Andrew Stellman
 
May 26, 2010  Sep 01, 2010
Printed
Page 354
Second block of code at the top

(This is the author submitting errata.)

In this line of code in the second code block at the top of page 354:


Console.WriteLine(duck.Size.ToString() + "-inch " + Kind);

replace "Kind" with "duck.Kind.ToString()"

Also, change this annotation: The + operator automatically
calls the KindOfDuck enum's ToString() method.
to this: You can also leave off ".ToString()" and the + operator will
call it automatically.

Andrew Stellman
Andrew Stellman
 
May 26, 2010  Sep 01, 2010
PDF
Page 160
Code

(Important Note: I do not speak English!)

These fixes apply to HitTheKeys Game code that is between pages 160 and 163.


1) For events related to Timer1 take effect insert the line of code in the method:

public Form1()
{
InitializeComponent();
timer1.Start();// <-- HERE!!!
}

2) For the keyboard-related events have the expected effect, the _KeyDown event must be created for listBox1 and not for Form1.

3) If the maximum difficultyProgressBar is not changed to a value greater than 800, the program has a bug.

Note from the Author or Editor:
We had a production error that caused a box with text to be deleted from page 162. The "Hit the Keys" game won't work without it. We're really sorry for any frustration that this may have caused!

Here's what the box should say:

Before you go on, there are three properties you need to set. Set the Timer control's Enabled property to True, the ProgressBar control's Maximum property to 701, and the Form's KeyPreview property to True. Take a minute and figure out why you need those properties. What happens if you don't set them?

Enio Brito  May 17, 2010  May 20, 2011