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 ix
Table of Contents (Summary), chapter 8

"enums" s/b "Enums"

Anonymous    Jan 01, 2008
Printed
Page ix
Table of Contents (Summary), chapter 11

"events" s/b "Events"

Anonymous    Jan 01, 2008
Printed
Page ix
Table of Contents (Summary)

TOC summary ends with Lab 3. Doesn't include "appendix i: leftovers", starting on page 703.

Anonymous    Jan 01, 2008
Printed
Page x
Table of Contents, entry for page 5

"startbuilding" s/b "start building"

Anonymous    Jan 01, 2008
Printed
Page xv
1st paragraph, last sentence.

"You'll make your object's data private, add methods to protect how that data is accessed." s/b "You'll make your object's data private, and add methods to protect how that data is accessed."

Anonymous    Jan 01, 2008
Printed
Page xxii, 483
1st paragraph, 5th line.

"subscibe" s/b "subscribe"

Anonymous    Jan 01, 2008
Printed
Page xxviii
fifth TOC item

This should be "#5 Windows Presentation Framework" -- it's missing the # at the beginning.

Anonymous    Jan 01, 2008
Printed
Page xxxvi
"Setting up Visual Studio 2008 Express Edition", 3rd bullet point, 2nd line

Missing period. "installation That should" s/b "installation. That should"

Anonymous    Jan 01, 2008
Printed
Page xxxvi
Screenshot

Screenshot on page replaced in reprint with an image that shows how the installer looks now that the final version of Visual Studio Express is out ( vs08setup.png). Even though the picture looks different all of the text stays the same.

Anonymous    Jan 01, 2008
Printed
Page xxxviii
2nd line from the bottom of the page

"execises" s/b "exercises"

Anonymous    Jan 01, 2008
Printed
Page xxviiii
Header and first line of body text

In the header and first line of body text change "Windows Presentation Framework" to "Windows Presentation Foundation".

Anonymous    Sep 01, 2008
Printed
Page 1

Here are two interfaces. IClown defines a clown who honks his horn and has a funny thing. IScaryClown inherits from clown. A scary clown does everything a clown does, plus he has a scary thing and scares little children.

Anonymous    Jan 01, 2008
Printed
Page 2

The FunnyFunny class implements the IClown interface. We made the funnyThingIHave field protected so that it can be accessed by any instance of a subclass of FunnyFunny.

Anonymous    Jan 01, 2008
Printed
Page 3

The ScaryScary class implements the IScaryClown interface. It also inherits from FunnyFunny, and since FunnyFunny implements IClown, that means ScaryScary does too. Take a look at how the ScareLittleChildren() method accesses the funnyThingIHave backing f

Anonymous    Jan 01, 2008
Printed
Page 4

Here's a button that instantiates FunnyFunny and ScaryScary. Take a look at how it uses as to downcast someFunnyClown to an IScaryClown reference.

Anonymous    Jan 01, 2008
Printed
Page 9
- top left annotation ("The toolbar has buttons...")

This is supposed to be a filled-in answer. There should be dotted-line blanks under it.

Anonymous    Jan 01, 2008
Printed
Page 10

remove the top right annotation "We've blown up..."

Anonymous    Jan 01, 2008
Printed
Page 11
first question, last two lines

Change "writes the action code, or the code that does the work" to "writes the code that actually does the work"

Anonymous    Jan 01, 2008
Printed
Page 11
fifth question and answer

This entire question and answer should be changed. Here's the new Q and A: Q: Can I change the names of the files the IDE generates for me? A: Absolutely. When you create a new project, the IDE gives you a default form called Form1 (which has files called Form1.cs, Form1.Designer.cs and Form1.resx). But you can use the Solution Explorer to change the names of the files to whatever you want. By default, the names of the files are the same as the name of the form. If you change the names of the files, you'll be able to see in the Properties window that form will still be called Form1. You can change the name of the form by changing the "(Name)" line in the Properties window. If you do, the filenames won't change. C# doesn't care what names you choose for your files or your forms (or any other part of the program). But if you choose good names, it makes your programs easier to work with. For now, don't worry about names -- we'll talk a lot more about how to choose good names for parts of your program later on.

Anonymous    Jan 01, 2008
Printed
Page 13
middle

1. It is Not the Size property but the "Size Mode" property that we change to "Zoom" 2. The book says, setting the "size mode" property to "zoom" will match the size of the picture box control to the size of the picture we put in it, but actually it is the reverse. The size of the picture/image will be changed to match the size of the picturebox control. 3. I love you guys!! (and it is not an error in the book!)

Note from the Author or Editor:
In the third line of text for step 2, change "Size property" to "Size Mode property"

Anonymous  Oct 05, 2008 
Printed
Page 13
step #2

Add an annotation pointing to the paragraph for #2 that says: You can also use the "Properties" window in the IDE to set the Size property. The little black arrow is just there to make it easy to access the most common properties of any control.

Anonymous    Jan 01, 2008
Printed
Page 13
In the text under step #3, change this text: "Click Import, find your logo, and you're all set:"

to this: You'll see a Select Resource window pop up. Click the "Local Resource" radio button to enable the "Import..." button at the top of the form. Click that button, find your logo, and you're all set: Add a new annotation to this page underneath the middle one that starts 'Choose "Zoom"' with an arrow pointing up at that annotation. It should say: Then click "Choose Image" to bring up the Select Resource dialog box so you can import a local resource.

Anonymous    Jan 01, 2008
Printed
Page 14
Change the text in the middle annotation from this

If you click on Form1.resx in the Solution Explorer, you can see the logo that you imported. to this: Go to the Solution Explorer and click on the plus icon next to Form1.cs to expand it (if it's not already expanded). This will display two files: Form1.Designer.cs and Form1.resx. Double-click on Form1.resx, click on the arrow next to "Strings", and select "Images" from the drop-down list (or hit Ctrl-2) to see the logo that you imported. Add an annotation pointing to the third screenshot on the page that's displaying pictureBox1.Image. The annotation should read: If you chose the other "Import..." button from the Select Resource dialog on the last page, then your image will show up in the Resources folder in the Solution Explorer instead. Don't worry -- just go back to Select Resources, choose "Local Resource", and re-import the image into the resources and it'll show up here.

Anonymous    Jan 01, 2008
Printed
Page 18
Insert a new #2 bullet between the picture and the current #2 bullet that says

Click on the Add button in the Add New Item window.

Anonymous    Jan 01, 2008
Printed
Page 19
Bottom-Left paragraph

"queries that you are stored" should be "queries that are stored"

Anonymous    Jan 01, 2008
Printed
Page 21

Add an annotation that points to the IsIdentity line in the screenshot on this page that says "You'll need to click on the right column and select Yes from the drop down next to IsIdentity to designate ContactID as your record Identifier."

Anonymous    Jan 01, 2008
Printed
Page 22
First paragraph

Instead of saying "you're going to track", the book says "your going to track"

Anonymous    Jan 01, 2008
Printed
Page 22
Laverne Smith's email address is missing a period. It should be

laverne.smith@xyzindustries.com

Anonymous    Jan 01, 2008
Printed
Page 25
1st paragraph

"the other five columns" should read "the other six columns"

Note from the Author or Editor:
In the second line of body text, change "the other five columns" to "the other columns"

Jeff Hickman  Feb 04, 2010 
Printed
Page 26
top left corner

Add a note in the blank space in the top-left corner of the page: In very rare cases, a few people sometimes have problems getting the SQL database to work. If you run into any trouble, don't worry -- go to the Head First C# forum at http://headfirstlabs.com/hfcsharp/ for help troubleshooting the problem.

Anonymous    Jan 01, 2008
Printed
Page 26
Screenshot below step 2

Title bar of dialog should say "Microsoft Visual C# 2008 Express Edition" (not "...2005 Express Edition"). Image is otherwise fine as is.

Anonymous    Jan 01, 2008
Printed
Page 26
Change the headline from “Diagram your data so your application to access it” to “Diagram your data”

And replace the top paragraph of body text with: “The Visual Studio IDE is built to work with databases, and it comes with a lot of built-in tools that help you when you’re handling a lot of data. One of the most powerful tools you have is the database diagram, which you can use to view and edit complex relationships between the tables in your database. So let’s go ahead and build a database diagram for your database.”

Anonymous    Sep 01, 2008
Printed
Page 27
In the sidebar, change the second sentence from this

“The IDE then uses the database diagram to auto generate code to work with your database.” To this: “The IDE will read your database and build a database diagram for you automatically.”

Anonymous    Sep 01, 2008
Printed
Page 29
Add an annotation pointing to one of the cards

Objectville Paper Company is in the United States, so the CEO writes dates so that 05/26/07 means May 26, 2007. If your machine is set to a different location, you may need to enter dates differently -- you might need to use 26/05/07 instead.

Anonymous    Jan 01, 2008
Printed
Page 29
Top Left Card

Phone number[(212)555-81125] has too many numbers in it. It should be (212)555-8125.

Anonymous    Jan 01, 2008
Printed
Page 29
Top Left Card and Middle Card

Both emails are missing the "." between xyzindustries and com

Anonymous    Jan 01, 2008
Printed
Page 31

In diagram, the file extension ".xsd" is missing from the end of the XML file, which should be labeled ContactDBDataSet.xsd.

Anonymous    Jan 01, 2008
Printed
Page 32
step 2, change the last sentence ("If you don't see the columns...") to this

Click the plus sign next to the People table to expand it -- you'll see the columns that you added to your table. When you click on the People table in the Data Sources window and drag it onto your form, the IDE automatically adds data controls to your form that the user can use to browse and enter data. By default it adds a DataGridView, which lets the user work with the data using one big spreadsheet-like control. Click the arrow next to the People table and select Details -- that tells the IDE to add individual controls to your form for each column in the table.

Anonymous    Jan 01, 2008
Printed
Page 32
an annotation that says: "This is the little arrow you should click on."

Change it to say this: "Click this arrow and choose 'Details' to tell the IDE to add individual controls to your form rather than one large spreadsheet-like data control."

Anonymous    Jan 01, 2008
Printed
Page 32

In the bottom annotation, change "fields" to "columns".

Anonymous    Jan 01, 2008
Printed
Page 36
Add a "Watch It!" to this page

Every time you build your program, the IDE puts a fresh copy of the database in the bin folder. This will overwrite any data you added when you ran the program. When you debug your program, the IDE rebuilds it if the code has changed -- which means that your database will sometimes get overwritten when you run your program in the IDE. If you run the program directly from the bin/debug or bin/release folder, or if use the installer to install it on your machine, then you won't see this problem.

Anonymous    Jan 01, 2008
Printed
Page 39
bottom right-hand annotation

Add this sentence to the annotation: "They're part of ContactDB.mdf database file, which gets installed along with your program."

Anonymous    Jan 01, 2008
Printed
Page 44

Remove the word "just" from the bottom annotation ("The Properties window in the IDE is a really easy way").

Anonymous    Sep 01, 2008
Printed
Page 45
In the code at the very bottom of the page, change

this.Text = "Contacts"; to this.Text = "Objectville Paper Company contact list";

Anonymous    Jan 01, 2008
Printed
Page 49
top annotation, fourth line

change "select it" to "tell the IDE to fill it in for you"

Anonymous    Jan 01, 2008
Printed
Page 51
bottom annotation, sixth line

Change: the designer tab to: the tab labeled "Form1.cs [Design]"

Anonymous    Jan 01, 2008
Printed
Page 52
third annotation

The underline isn't lined up with the words "inside a class"

Anonymous    Jan 01, 2008
Printed
Page 52
bottom annotation

Add another annotation underneath this one pointing up at it that says: "You'll see slightly different using lines if you're using Visual Studio 2005"

Anonymous    Jan 01, 2008
Printed
Page 55
– sidebar (“Every C# program must have…”)

Add an annotation pointing down at this sidebar that says: “Technically, a program can have more than one Main() method, and you can tell C# which one is the entry point… but you won’t need to do that now.”

Anonymous    Sep 01, 2008
Printed
Page 56
Top paragraph, second sentence

Change "Let's remove the Main method" to "Open up the program you wrote in Chapter 1 and remove the Main method"

Anonymous    Jan 01, 2008
Printed
Page 57
First paragraph, second line

Change "messagebox" to "MessageBox"

Anonymous    Jan 01, 2008
Printed
Page 63
Dictionary definition

Put a period after "adapted" and capitalize "The" in "The drill's"

Anonymous    Jan 01, 2008
Printed
Page 65
Change the loop in the middle of the page to

for (int i = 0; i < 8; i = i + 2)

Anonymous    Jan 01, 2008
Printed
Page 69
code at top of page should be

if ((someValue == 3) && (name.Equals("Joe")))

Anonymous    Jan 01, 2008
Printed
Page 69
annotation that starts "The second part"

Add a sentence to the end of the annotation: The test is run before the code block, and the block is executed only if the test is true.

Anonymous    Jan 01, 2008
Printed
Page 69
annotation that starts with "This is where the loop"

Add a sentence to the end of the annotation: This is called the iterator, and it's run immediately after all of the statements in the code block. (make the color of "immediately after" black and underline it)

Anonymous    Jan 01, 2008
Printed
Page 69
top annotation

This line checks someValue to see if it's less than 3 ......... should be This line checks someValue to see if it equals 3 ......... Change the top annotation from “to see if it’s less than 3” to “to see if it’s equal to 3”

Anonymous    Sep 01, 2008
Printed
Page 71
Annotation for Loop #5

The annotation "Hint: q starts out equal to zero" is wrong as q starts out equal to 2 as initialized by the header of the for loop.

Note from the Author or Editor:
In the bottom right annotation, change "equal to zero" to "equal to 2"

Anonymous  Aug 12, 2008 
Printed
Page 71
lower left-hand corner

Add an annotation pointing up at the Sharpen that says: "Remember, a for loop always runs the conditional test at the beginning of the block, and the iterator at the end of the block"

Anonymous    Jan 01, 2008
Printed
Page 73

Change this: “Yes, there are a few namespaces you’re not allowed to use.” To this: “Technically there aren’t any namespaces you’re not allowed to use. But there are several namespaces that .NET uses, and it’s a bad idea to use them yourself.”

Anonymous    Sep 01, 2008
Printed
Page 73

Change this: and System.Math, which has mathematical functions. To this: and System.IO, which lets you work with files and data streams.

Anonymous    Sep 01, 2008
Printed
Page 76
in step #2, change this text: "from 0 to 254"

to this: "from 0 to 253"

Anonymous    Jan 01, 2008
Printed
Page 76

Change the second annotation to: “This line tells the program to stop your loop momentarily and do the other things it needs to do, like refresh the form, check for mouse clicks, etc. Try taking out this line and seeing what happens. The form doesn’t redraw itself, because it’s waiting until the loop is done before it deals with those events.” Add another annotation pointing up at it: “Later on in the book, you’ll learn about a better way to let your programs do more than one thing at a time! But for now, use Application.DoEvents() to make sure your form stays responsive while it’s in a loop.”

Anonymous    Sep 01, 2008
Printed
Page 79
add an annotation pointing to the second for line in the code

We used "&& Visible" instead of "&& Visible == true". It's just like saying "if it's visible" instead of "if it's true that it's visible" -- they mean the same thing.

Anonymous    Jan 01, 2008
Printed
Page 79
bottom paragraph, third line, boldfaced courier text

Change "&& Visible == true" to "&& Visible"

Anonymous    Jan 01, 2008
Safari Books Online
82
Code Magnets solution

The solution for Code Magnets given is not the only solution. Try: string Result = ""; //declarations and initial assignments int x = 3; while (x > 0) { if (x > 2) { Result = Result + "a"; } if (x == 2) { Result = Result + "b c"; } x = x - 1; Result = Result + "-"; if (x==1) { Result = Result + "d"; x = x - 1; } } MessageBox.Show(Result);

Note from the Author or Editor:
Add an annotation at the very bottom of the page: This Code Magnets has more than one solution! Can you find another way to arrange the magnets and get the same result?

Anonymous  Oct 20, 2008 
Safari Books Online
89
Step 3

The book gives "1en" in the code on page 89. That did not work. My youngest son pointed out that "You can't prefix variables with numbers." The correction is to change "1en" to "en1". Then the program worked properly.

Note from the Author or Editor:
Change "len" to "length" in the text for step #3 -- make sure the font is kept as courier new: Then double-click on the button and have it run this code that calls BlahBlahBlah() and assigns its return value to an integer called length: Then change the two occurrences of "len" in the code that follows to "length": int length = Talker.BlahBlahBlah(textBox1.Text, (int) numericUpDown1.Value); MessageBox.Show(ďThe message length is Ē + length);

Jerome Smith  Jan 12, 2009 
Printed
Page 89
Step 2 Paragrapgh 2 (right after the code), line 3

The line says "When it's called, it pops up a MessageBox with the message repated..." repated is not repeated - grammatical error.

Anonymous  Dec 05, 2008  Sep 01, 2008
Printed
Page 89
second paragraph under step 2, second sentence

"repated" should be "repeated"

Anonymous    Sep 01, 2008
Printed
Page 89

"... a number of its numberOfTimes parameter." change to: "... a number for its numberOfTimes parameter."

Anonymous    Sep 01, 2008
Printed
Page 93
Under "Check it out for yourself!"

"Open any project that uses a button called button1, and use the IDE to search the entire project for the text "new button1". should read "Open any project that uses a button called button1, and use the IDE to search the entire project for the text "button1 = new".

Anonymous    Jan 01, 2008
Printed
Page 93
last paragraph

In the text: search the entire project for the text Ůbutton 1 = newÓ. remove the space in "button 1" -- it should be "button1 = new".

Anonymous    Sep 01, 2008
Printed
Page 94-96

semicolon missing after "Navigator navigator1 = new Navigator()" in the second line of code under step 2 on page 94, fourth line of code on page 95, fourth line of code on page 96

Anonymous    Jan 01, 2008
Printed
Page 97
Third paragraph, third line

Change "Talker()" to "Talker" -- remove the parentheses

Anonymous    Jan 01, 2008
Printed
Page 98
top annotation

Change "is a special kind of field" to "is very similar to a field"

Anonymous    Jan 01, 2008
Printed
Page 102
top left annotation, fifth line

Change "T()" to "T" -- remove the parentheses

Anonymous    Jan 01, 2008
Printed
Page 102
code example for bulleted point #1

The current example says: int t = m.chkTemp(); if (t > 160) { T obj = new T(); tb.clsTrpV(2); ics.Fill(); ics.Vent(); m.airsyschk(); } The line with the tb.clsTrpV(2) I believe should be obj.clsTrpV(2) or the line before should be changed to T tb = new T(); which is a better solution since tb could be short for turbine so that tb.clsTrpV(2) is for "close the trip throttle valve on turbine #2" which is the first step in the specification manual example at the bottom of page 102

Note from the Author or Editor:
In the code block under step 1, change the third line: T obj = new T(); To this: T tb = new T();

Anonymous  Jun 25, 2008  Sep 01, 2008
Printed
Page 102
code example for bulleted point #1

The current example says: int t = m.chkTemp(); if (t > 160) { T obj = new T(); tb.clsTrpV(2); ics.Fill(); ics.Vent(); m.airsyschk(); } The line with the tb.clsTrpV(2) I believe should be obj.clsTrpV(2) or the line before should be changed to T tb = new T(); which is a better solution since tb could be short for turbine so that tb.clsTrpV(2) is for "close the trip throttle valve on turbine #2" which is the first step in the specification manual example at the bottom of page 102. In the code block under step 1, changed the third line: T obj = new T(); To this: T tb = new T();

Anonymous    Sep 01, 2008
Printed
Page 105
Annotation for the third class

Fill in its name and method. Should be: Fill in its name and methods.

Note from the Author or Editor:
This is p107 in the second edition. Bottom annotation: change "method" to "methods"

Anonymous  Feb 11, 2010 
Printed
Page 108
Class diagram in the upper right-hand corner

"ClassMaker" should be changed to "CandyMaker" -- it's currently the wrong solution to the problem.

Anonymous    Jan 01, 2008
Printed
Page 110
text for Step 3

first off, this errata submission form needs a field for the printing revision (and a hint telling users how to find it). Mine was the [9/08] version. This is the latest version as far as I know. Assuming the code on page 111 is left as-is, the text for Step 3 at the bottom of page 110 is seriously incorrect. I would revise the sentence after the Step 3 heading text to be: "We'll use each guy's GiveCash() method to transfer cash FROM a guy, and we'll use his ReceiveCash() method to transfer cash TO a guy." This is in fact the EXACT OPPOSITE the current text which says: "We'll use each guy's GiveCash() method to give cash to a guy, and we'll use his ReceiveCash() method to take cash back from him." In the graphical text associated with Step 3, there are 4 instances of ReceiveCash() that need to be changed to GiveCash(). For the graphics at the bottom of page 110 to be correct, the only way the Joe object can go from having $100 to having $75 is by having a calling program invoke joe.GiveCash(25), NOT joe.ReceiveCash(25). Those two method names, GiveCash() and ReceiveCash(), are from the point of view of the object (as is made clear in the text on page 111). This caused me quite a bit of confusion.

Note from the Author or Editor:
Change the bottom annotation to this: The method returns the number of bucks that were taken. We called it "ReceiveCash" because the form's receiving cash from Joe. Do you think we chose good method names? Can you think of better ones?

clyde underwood  Apr 19, 2009 
Printed
Page 110

top annotation, third line: change "lives" to "live"

Anonymous    Jan 01, 2008
Printed
Page 110
last line

The two methods used in the Guy class are : GiveCash() ReceiveCash() In that line ( and in the pictures ) instead you can find : joe.TakeCash() The word TakeCash() appears six times on this page: in the class diagram box in the upper right-hand corner, in the body text under step 3, above the arrow in the diagram under step 3, twice in the lower right-hand annotation, and once in the annotation directly under step 3. These were all changed to ReceiveCash().

Anonymous    Sep 01, 2008
Printed
Page 112
step 1

In the title line, change "six labels" to "three labels" In the first line of the paragraph, change "The labels on the right-hand side of the form" to "The top two labels". In the second line of the paragraph, change "the third label on the right" to "the third label" In the last line, change "label4 and label5" to "label1 and label2"

Anonymous    Jan 01, 2008
Printed
Page 114
first question, first, fourth and eighth lines:

change "bob variable" to "bob field"

Anonymous    Jan 01, 2008
Printed
Page 116
2nd paragraph

A program to help a zoo keeper track her animals'feeding schedules might have classes for different kinds of food and types of animals. Should be: A program to help a zoo keeper track her animals' feeding schedules might have classes for different kinds of food and types of animals.

Note from the Author or Editor:
This is p118 in the second edition -- there's a space missing before "feeding" in the first line of the second bullet

Anonymous  Feb 12, 2010 
Printed
Page 117
Top left bold text

"Object intializers save you time and..." s/b "intializers".

Note from the Author or Editor:
In the first line of the sidebar, change "intializers" to "initializers"

Anonymous  Nov 29, 2011 
Printed
Page 124

In the first line of body text, change boldfaced text “value types” to “types”. In the first boldfaced heading, change “Value types” to “Types”.

Anonymous    Sep 01, 2008
Printed
Page 124

In the second bulleted list, second bullet, change this: “-127 to 128” To this: “-128 to 127”

Anonymous    Sep 01, 2008
Printed
Page 124

In the second bulleted list, second bullet, change this: “-32767 to 32768” To this: “-32768 to 32767”

Anonymous    Sep 01, 2008
Printed
Page 125
add an annotation pointing to the "decimal" bullet at the top of the page

When your program needs to deal with currency, you usually want to use a decimal to store the number.

Anonymous    Jan 01, 2008
Printed
Page 125
third section, first three sentences that start "Did you notice how the byte type..."

This is inaccurate, and we need to replace the first three sentences with: Sometimes you need to store a single character like Q or 7 or $, and when you do you'll use the char type. (make sure "char" is in courier) Also, add this sentence to the end of that paragraph: You write an escape sequence in your C# code using to characters, but your program stores each escape sequence as a single character in memory.

Anonymous    Jan 01, 2008
Printed
Page 125

In the third boldfaced heading, change “built-in value types” to “built-in types” In the Brain Power at the bottom of the page, change -32,767 to -32,768

Anonymous    Sep 01, 2008
Printed
Page 126

* Change this: “scientific application where the numbers need to be extremely accurate, the decimal type has the most precision.” To this: “financial application where you’ll be storing currency values, you’ll want to use the decimal type.” * In the bottom paragraph, change “There’s no set size for a string variable” to “There’s no set size for a string object” * Remove this annotation: string is pretty unique. It’s the only data type without a set size, except for objects (think about that for a bit).

Anonymous    Sep 01, 2008
Printed
Page 129

* In the thought bubble, change “casting this whole time?” to “converting types all along?” * In the heading underneath it, change “casts for you” to “converts for you” * In the second line of body text underneath that, change “a lot of casting” to “a lot of converting” * In the third-to-last line in that paragraph, change “automatically casts” to “automatically converts” * In the second-to-last line on the page, change “casts myInt” to “converts myInt”

Anonymous    Sep 01, 2008
Printed
Page 130

In the bottom paragraph, change this: “(an argument is another name for a method’s parameter)” To this: “(an argument is what C# calls the value that you’re passing into a method’s parameter)”

Anonymous    Sep 01, 2008
Printed
Page 130

Change “and converted the result to a double.” to “and the = operator converted the result to a double.”

Anonymous    Sep 01, 2008
Printed
Page 131
Last [normal] paragraph

"Now try passing it a boolean, but assigning the return value to a long" should change to: "Now try passing it a boolean but assigning the return value to a string."

Anonymous    Jan 01, 2008
Printed
Page 131

Add this to the end of the first paragraph: “(Sometimes C# can do the conversion automatically – like if your method expects an int, but you pass it a short – but it can’t do that for ints and strings.)”

Anonymous    Sep 01, 2008
Printed
Page 132

* In the instructions, change “know them all” to “know a lot of them” [p161, too] * Add an annotation to the top of the page: “Actually, C# does give you a way to use reserved keywords as variable names, by putting @ in front of the keyword. You can do that with non-reserved names too, if you want to.”

Anonymous    Sep 01, 2008
Printed
Page 133 and 134

instructions - replace "odometer" with "mileage reading from the car's odometer"

Anonymous    Jan 01, 2008
Printed
Page 137
headline

Change "Objects are variables, too" to "Objects use variables, too"

Anonymous    Jan 01, 2008
Printed
Page 139
Diagram's arrow text, bottom right

"Every one of these labels is reference variable, but ...Ś” Change the annotation just underneath and to the right of the picture to this: “Every one of the labels is a different reference variable, but they all point to the SAME Guy object.”

Anonymous    Sep 01, 2008
Printed
Page 140
Cooemt beginning "The first line had ...", just above paragraph 2

This is from the 4/08 printing. In 1 Here's some code that creates an object. Guy joe = new Guy(); {Name = "Joe". Cash = 50}; The explanation says, "The first line had a declaration that created the label. The second line created the object and slapped a label on it." Actually, the first line declares a Guy reference variable (joe) as well as creating a new Guy object. The second line merely populates two fields and is superfluous. Moreover, the Name could be anything (I made it Jack in my test) but the object would still be referenced as joe (joe.Name = "Jack"). This might seem trivial, but to an old VB programmer transitioning to C#, objects and references can be confusing. Precision in the explanation helps.

Note from the Author or Editor:
Change the top annotation to this: When you use the 'new' statement, you're telling C# to create an object. When you take a reference variable like 'Joe' and assign it to that object, it's like you're slapping a new label on it.

Anonymous  Jun 30, 2008  Sep 01, 2008
Printed
Page 140
Cooemt beginning "The first line had ...", just above paragraph 2

This is from the 4/08 printing. In 1 Here's some code that creates an object. Guy joe = new Guy(); {Name = "Joe". Cash = 50}; The explanation says, "The first line had a declaration that created the label. The second line created the object and slapped a label on it." Actually, the first line declares a Guy reference variable (joe) as well as creating a new Guy object. The second line merely populates two fields and is superfluous. Moreover, the Name could be anything (I made it Jack in my test) but the object would still be referenced as joe (joe.Name = "Jack"). This might seem trivial, but to an old VB programmer transitioning to C#, objects and references can be confusing. Precision in the explanation helps. Change the top annotation to this: When you use the “new” statement, you’re telling C# to create an object. When you take a reference variable like “Joe” and assign it to that object, it’s like you’re slapping a new label on it.

Anonymous    Sep 01, 2008
Printed
Page 141
Crossword puzzle, 3 Down

There is no mention of camel case prior to page 141. The index shows camel case first being introduced on page 201.

Anonymous    Jan 01, 2008
Printed
Page 145

Change the last annotation to: "The WhoAmI() method should pop up this message box. Make sure the message includes the ear size and the title bar includes the name."

Anonymous    Jan 01, 2008
Printed
Page 145 and 146
instructions

Change "Make two elephant instances and then have them switch properties" to "Make to elephant instances and then swap the reference variables that point to them"

Anonymous    Jan 01, 2008
Printed
Page 146
Add this annotation

strings and arrays are different from all of the other data types you’ve seen because they’re the only ones without a set size (think about that for a bit).

Anonymous    Sep 01, 2008
Printed
Page 147
Step 2

lloyd = Lucinda; should be: lloyd = lucinda;

Anonymous    Jan 01, 2008
Printed
Page 149
tool tip box, third line

Change "field" to "property"

Anonymous    Jan 01, 2008
Printed
Page 149
An array's length box

last line change "nubmered" to "numbered"

Anonymous    Sep 01, 2008
Printed
Page 150
Item 2 , 1st line

Currently: "Add a GetMenItem()..." Should be: "Add a GetMenuItem()..."

Anonymous  May 19, 2008  Sep 01, 2008
Printed
Page 151
Step 3 "Build your form" first sentence

It reads "label1 through lablel6" and it should be "label1 through label6"

Anonymous    Sep 01, 2008
Printed
Page 152
step 1, second and third sentences

Change "method" to "parameter"

Anonymous    Jan 01, 2008
Printed
Page 153
Dumb Questions, middle column, last line of answer

Currently: "... reference ot it somewhere." Should be: "... reference to it somewhere."

Note from the Author or Editor:
'ot' should be 'to

Anonymous  May 19, 2008  Sep 01, 2008
Safari Books Online
153
There are No Dumb Questions

The Line: Look inside the InitializeComponent() method - You'll find "new Form1(); Should read as: Look inside the Main() method - You'll find "new Form1(); I am not sure if you consider this is serious or minor technical problems. Since the method InitializeComponent doesn't exist in Program.cs I marked this as serious.

Note from the Author or Editor:
Change InitializeComponent() to Main()

Anonymous  Jul 18, 2008  Sep 01, 2008
Printed
Page 153
There are No Dumb Questions

The Line: Look inside the InitializeComponent() method - You'll find "new Form1(); Should read as: Look inside the Main() method - You'll find "new Form1(); Changed “InitializeComponent()” to “Main()”.

Anonymous    Sep 01, 2008
Printed
Page 153
Dumb Questions, middle column, last line of answer

Currently: "... reference ot it somewhere." Should be: "... reference to it somewhere."

Anonymous    Sep 01, 2008
Printed
Page 154
first answer, sixth line

Change "(non-static) a" to "a (non-static)"

Anonymous    Jan 01, 2008
Printed
Page 154
bullet points, right-hand column, third bullet

Add a colon after "labels" -- "References are like labels:"

Anonymous    Jan 01, 2008
Printed
Page 154

* In the first bullet, change 256 to 255. * Swap the second and first bullets, so the word “ALWAYS” is at the top. Add this annotation above the Bullet Points box pointing to the word “ALWAYS”: “There’s actually a very specific case where you don’t declare a type – you’ll learn about it when you use the ‘var’ keyword in chapter 14.” * Change bullet 5 from this: “The compiler won’t let you set a variable equal to a value of a different type unless you cast it.” To this: “There are a few types (like short to int) that C# knows how to convert automatically. Other than those, the compiler won’t let you set a variable equal to a value of a different type unless you cast it.”

Anonymous    Sep 01, 2008
Printed
Page 154

In the last answer, sixth line, change "with an class" to "with a class"

Anonymous    Sep 01, 2008
Printed
Page 166
class diagram and code for Greyhound

Change "MyRandom" to "Randomizer" in two places -- it's in the class diagram and in the sixth line of the code next to it Add an annotation (there should be room underneath the line of code) that says: You only need one instance of Random -- each Greyhound's Randomizer reference should point to the same Random object.

Anonymous    Jan 01, 2008
Printed
Page 167
code at the top of the page

add an annotation pointing to "public Label MyLabel; // My Label" that reads: "Once you set MyLabel to one of the labels on the form, you'll be able to change the label's text using MyLabel.Text. And the same goes for MyRadioButton!"

Anonymous    Sep 01, 2008
Printed
Page 169
Top, Center

The suggested code for MyBet cannot be used because it requires knowledge of constructors, which isn't discussed in the book until p. 197. Per Andrew, the code should read as follows: MyBet = new Bet() { Amount = 7, Dog = 3, Bettor = this }; Change the code on the top right arrow from: MyBet = new Bet(7, 3, 8) To: MyBet = new Bet() { Amount = 7, Dog = 3, Bettor = this };

Anonymous    Sep 01, 2008
Printed
Page 170

Add an annotation pointing to the screenshot that says: Make sure you set each PictureBox's SizeMode property to Zoom

Anonymous    Jan 01, 2008
Printed
Page 176
class diagram

Remove "HealthyOption" from the class diagram

Anonymous    Jan 01, 2008
Printed
Page 178
Excercise solution

Page 178 - Exercise solution says const in CostOfFoodPerPerson = 25; When on page 176, the book tells the reader to use public const int CostOfFoodPerPerson = 25;

Note from the Author or Editor:
On page 178, change this line (2nd line of code): const int CostOfFoodPerPerson = 25; to this: public const int CostOfFoodPerPerson = 25;

Anonymous  Sep 30, 2008 
Printed
Page 183
top - "The Problem Up Close"

the "Close" is cut off

Anonymous    Jan 01, 2008
Printed
Page 189
Point 3

Change 94 to 54 (to match page 190)

Note from the Author or Editor:
In the second edition, this is page 195

Jeff Hickman  Apr 13, 2010 
Printed
Page 190
Last annotation (bottom right)

Change "loyalCustomerAmount" to loyalCustomerOrderAmount to match the code on p189 & p190

Note from the Author or Editor:
In the second edition, this is on page 196

Jeff Hickman  Apr 13, 2010 
Printed
Page 190
change this line of code

return cookieRecipe + " " + secretIngredient; to this: return cookieRecipe + " and the secret ingredient is " + secretIngredient;

Anonymous    Jan 01, 2008
Printed
Page 190
- in # 3. int loyalCustomerAmount = 94

change 94 to 54

Anonymous    Jan 01, 2008
Printed
Page 190
in #5. mySuperChef.cookieRecipe = "get 3 eggs..."

Make the "g" uppercase -- "Get 3 eggs..."

Anonymous    Jan 01, 2008
Printed
Page 190
- add an annotation at the bottom of the page pointing to the answer to #7

Even though you created a local variable called loyalCustomerAmount and set it to 54, that didn't change the object's loyalCustomerAmount value, which is still 60 -- so it won't print the secret ingredient.

Anonymous    Jan 01, 2008
Printed
Page 190
first item circled

The instructions ask the reader to circle items that won't compile. The following line has "const" circled yet it will compile:private const int loyalCustomerOrderAmount = 60; Remove the top annotation, arrow and circle around the word “const”.

Anonymous    Sep 01, 2008
Printed
Page 193
3rd annotation errata

3rd annotation, last line. The errata changed "private numberOfCows field" to "private numberOfCows property." Isn't field correct? Technically, numberOfCows is the backing field, NumberOfCows is the property. The other changes by this errata appear correct.

Note from the Author or Editor:
In the third errata, change the last three words from this: private numberOfCows property. to this: private numberOfCows field.

Anonymous  Nov 01, 2008 
Printed
Page 193
last annotation

page 193, last annotation, last sentence states "And when it queries the BagsOfFeed field it runs the get accessor, which returns 300." Is this referring to an unmentioned BagsOfFeed property? Also, we just changed NumberOfCows to 20, which sets numberOfCows to 20. According to the bottom of page 192, BagsOfFeed = numberOfCows * FeedMultiplier, and FeedMultiplier is a constant equal to 30. Therefore, BagsOfFeed should be 600. I would change the last sentence to "The set accessor causes a recalculation of BagsOfFeed so that myFarmer.BagsOfFeed now equals 600."

Note from the Author or Editor:
On page 192, add this line of code: public int BagsOfFeed; as the second line of the first block of code, indented to match the "numberOfCows" line. So it should look like this: class Farmer { public int BagsOfFeed; private int numberOfCows; } You'll need to change the arrow of the top annotation so that it doesn't overlap the code. Finally, change that annotation to this: We want BagsOfFeed to change every time someone changes then number of cows. So weíd better make this field private so nobody can change it without also changing BagsOfFeedóif they get out of sync, thatíll create bugs!

Anonymous  Nov 01, 2008 
Printed
Page 193
- bottom block of code

Add this line of code above "public int GetNumberOfCows()": public const int FeedMultiplier = 30; with this annotation pointing to it: "The farmer needs 30 bags of feed for each cow."

Anonymous    Jan 01, 2008
Printed
Page 193

In the body text, change this: “every time a field is called” To this: “every time a property is used” And in the third and fourth annotations, change “NumberOfCows field” to “NumberOfCows property”

Anonymous    Sep 01, 2008
Printed
Page 193

In the second annotation, change “You use properties” to “You’ll often use properties”

Anonymous    Sep 01, 2008
Printed
Page 194
- top left annotation

Change the first few words from this: Name this button Calculate to this: Name this button "calculate"

Anonymous    Sep 01, 2008
Printed
Page 195
change

"Add a button the form that executes this statement." to: "Add a button to the form that executes this statement."

Anonymous    Jan 01, 2008
Printed
Page 195
last line of body text on the bottom of the page

Add this right before the last sentence that starts "Now your Farmer class...": You can't modify BagsOfFeed from outside the Farmer class -- you'll need to remove that line in order to get your code to compile, so remove the button from the form.

Anonymous    Sep 01, 2008
Printed
Page 196
step #1

Add an annotation pointing to the second line of code ("public int FeedMultiplier"): This automatic property acts just like an int field. It has a public get, which means any other class can read the value of FeedMultiplier. But since its set is private, that makes it read-only -- it can only be set by an instance of Farmer.

Anonymous    Jan 01, 2008
Printed
Page 196

* body text at the top of the page Change the last sentence from this: So let’s change it to a read-only automatic property. To this: So let’s change it to a read-only property that uses a backing field. * New screenshot * In step 1, change this: Use prop-tab-tab to add a read-only automatic property: public int FeedMultiplier { get; private set; } to this: (make sure the code is still in courier): Use prop-tab-tab to add a read-only property. But instead of adding an automatic property, use a backing field: private int feedMultiplier; public int FeedMultiplier { get { return feedMultiplier; } } * Change the annotation to this: This property acts just like an int field, except instead of storing a value it just returns the backing field, feedMultiplier. And since there's no set accessor, it's read-only. It has a public get, which means any other class can read the value of FeedMultiplier. But since its set is private, that makes it read-only—it can only be set by an instance of Farmer. * Add another annotation pointing to the "private int feedMultiplier" line: Since we changed FeedMultiplier from a public const to a private int field, we changed its name so it starts with a lowercase “f”. That’s a pretty standard naming convention you’ll see throughout the book. * In the third line of code under step 2, change "FeedMultiplier" to "feedMultiplier" (lowercase f).

Anonymous    Sep 01, 2008
Printed
Page 196
1st paragraph, line 3

In line 3 of the body text, change “You’ve seen how you poor” to “You’ve seen how poor”

Anonymous    Sep 01, 2008
Printed
Page 197-198
Here's a list of the things that need to change on pages 197 and 198

--- p197- In the body text on the top of p197, in the fourth line change this: very first thing that gets run when the class is created to this very first thing that gets run when the class is instantiated add a comma after private ("...fields that need to be initialized are private, then an object initializer...") In Step 1: Change the last sentence of the paragraph for step 1 from: "Then we’ll set the two properties." to "We'll change feedMultiplier from a const to an int. We'll need a value for it, so let's make sure it gets passed into the constructor. We'll use the constructor to set the number of cows, too." Right underneath that, change the code from this: public Farmer(int numberOfCows, int feedMultiplier) { FeedMultiplier = feedMultiplier; this.NumberOfCows = numberOfCows; } to this: private int feedMultiplier; public Farmer(int numberOfCows, int feedMultiplier) { this.feedMultiplier = feedMultiplier; NumberOfCows = numberOfCows; } In the second annotation in the left margin of p197, change "new()" to "new" and put it in Courier. Add two annotations to p197 pointing to the code "private int feedMultiplier;": * We'll change feedMultiplier from a const to an int field. * Since we changed FeedMultiplier from a public const to a private int field, we changed its name so its starts with a lowercase f. That's a pretty standard naming convention you'll see throughout the book. Also, in the annotation pointing to "NumberOfCows", remove "this." from "this.NumberOfCows" -- it should just be "NumberOfCows". p198 - the "Way Up Close" box at the top of the page Make sure the code in this box matches the code on page 197: private int feedMultiplier; public Farmer(int numberOfCows, int feedMultiplier) { this.feedMultiplier = feedMultiplier; NumberOfCows = numberOfCows; } In this annotation: We need to set the feed multiplier first, because the second statement calls the NumberOfCows set accessor, which needs FeedMultiplier to have a value in order to set BagsOfFeed. change "FeedMultiplier" to "feedMultiplier" (with a lowercase f) In this annotation: You’ll often see the this keyword a constructor. By calling this.NumberOfCows, we’re telling C# to set the NumberOfCows property using its public set accessor. Make sure it points to "this." in the "this.feedMultiplier = feedMultiplier;" line in the code. Then change the annotation to say this instead: We need a way to differentiate the field called feedMultiplier from the parameter with the same name. That's where the "this." keyword comes in really handy. Change this annotation: If you leave off “this.” then C# will call the private set accessor instead. Give it a shot—remove “this.” and see for yourself. to this: Since "this" is always a reference to the current object, this.feedMultiplier refers to the field. If you leave "this" off, then feedMultiplier refers to the parameter. So the first line in the constructor sets the private feedMultiplier field equal to the second parameter of the constructor. Also in the last paragraph of the No Dumb Questions answer, change: The InitializeComponent() method is called inside the form's constructor is so that the controls all get initialized... to: The InitializeComponent() method is called inside the form's constructor so that the controls all get initialized ---

Anonymous    Jan 01, 2008
Printed
Page 197

* Remove the first line of code ("private int feedMultiplier;") and the two annotations that point to it ("We'll change feedMultiplier..." and "Since we changed FeedMultiplier..."). * New screenshot * In the space that opened up by removing the line of code and two annotations, add one annotation with an arrow pointing down (hopefully the extra space will make the page look less cluttered): The 'this' keyword in this.feedMultiplier tells C# that you're talking about the field, not the parameter with the same name. * body text for step 1 Change this: We’ll change feedMultiplier from a const to an int. We’ll need a value for it, so let’s make sure it gets passed into the constructor. to this: Since we changed feedMultiplier from a const to an int, now we need an initial value for it. So let's make sure it gets passed into the constructor. (make sure you retain the Courier font for the keywords and variable names) * body text for step 2 Add this sentence to the end: Once you replace the new statement, both errors will go away and your code will work!

Anonymous    Sep 01, 2008
Printed
Page 198

* code in "Constructors Way Up Close" box Remove the first line of code ("private int feedMultiplier;"). It's not needed here, and this will let you move the rest of the code and the middle annotation up to create more space in the box. That will reduce the clutter. You can make the arrow under the top-left annotation shorter, and you can get rid of the arrow under the top-right annotation entirely and just have the bracket point to the annotation directly. * Watch It! box Change "numberOfCows" to "feedMultiplier" and "NumberOfCows" to "FeedMultiplier". (Make sure you retain the Courier formatting.) And change the hyphen in the sixth line to a colon. So the text should look like this: Did you notice how the constructor’s feedMultiplier parameter looks just like the backing field behind the FeedMultiplier property? If you wanted to use to the backing field in of the constructor, you’d use “this.”: feedMultiplier refers to the parameter, and this.feedMultiplier is how you’d access the private field.

Anonymous    Sep 01, 2008
Printed
Page 199
second answer

change "one that's declare inside a field and called..." to "one that looks ljust like a field to other objects, and called..."

Anonymous    Jan 01, 2008
Printed
Page 199
fourth answer, second paragraph

Remove the sentence "C# was designed to save you from writing redundant code." Also, change "get {" to "set {".

Anonymous    Jan 01, 2008
Printed
Page 199
sixth answer

Add a fourth line with just a closing bracket } to the first code block The second code block has a line break or indentation problem -- the third opening bracket { ran onto the next line and it looks odd. If you just expand the whole NDQ frame by a millimeter or two, it should correct the problem.

Anonymous    Jan 01, 2008
Printed
Page 199

* In the third answer, fifth line, change “when a field gets accessed” to “when a property gets accessed” * In the third answer, last line, change “getting or setting the field” to “getting or setting the property” * In the fourth answer, second paragraph, fourth line, change “type of the field” to “type of the property” * In the sixth answer, second line, change “read-only field” to “read-only property” * In the sixth answer, fourth line, change “ReadOnly field” to “read-only property” * In the sixth answer, second paragraph, second line, change “your field can only” to “your backing field can only” * In the sixth answer, second paragraph, fourth line, change “Password field” to “Password property”

Anonymous    Sep 01, 2008
Printed
Page 200
1st paragraph

In the "Sharpen your pencil" exercise, the instruction paragraph states: "The Form that is using this class has a new instance of CableBill called thisMonth and calls the GetThisMonthsBill() method with a button click." The CableBill class does not have a GetThisMonthsBill() method. It should reference the CalculateAmount() method.

Note from the Author or Editor:
In the third line of text at the top of the page, change this: GetThisMonthsBill() method to this: CalculateAmount() method

Anonymous  Aug 08, 2008 
Printed
Page 200
- this Sharpen Your Pencil needs to be redone.

Here's the new code for the class: public class CableBill { private int rentalFee; public CableBill(int rentalFee) { this.rentalFee = rentalFee; discount = false; } private int payPerViewDiscount; private bool discount; public bool Discount { set { discount = value; if (discount) payPerViewDiscount = 2; else payPerViewDiscount = 0; } } public int CalculateAmount(int payPerViewMoviesOrdered) { return (rentalFee - payPerViewDiscount) * payPerViewMoviesOrdered; } } and here's the new code for the three questions. question 1: CableBill january = new CableBill(4); MessageBox.Show(january.CalculateAmount(7).ToString()); question 2: CableBill february = new CableBill(7); february.payPerViewDiscount = 1; MessageBox.Show(february.CalculateAmount(3).ToString()); question 3: CableBill march = new CableBill(9); march.Discount = true; MessageBox.Show(march.CalculateAmount(6).ToString());

Anonymous    Jan 01, 2008
Printed
Page 201
- answer

Remove the ) at the end of the second paragraph Remove the ) at the end of #1. Then add this sentence to the end of #1: "(It's called camelCase because it starts with a lowercase letter, and additional words are uppercase so they resemble humps on a camel.)"

Anonymous    Jan 01, 2008
Printed
Page 201
second paragraph of first Answer at top

Add the following text to the beginning of the paragraph: "Case matters in C#. You can have two different variables called Party and party in the same method. It'll be confusing to read, but your code will compile just fine."

Anonymous    Sep 01, 2008
Printed
Page 202
The answers to the Sharpen Your Pencil on page 200 are

question 1: 28 question 2: won't compile question 3: 42

Anonymous    Jan 01, 2008
Printed
Page 203
Step 1 in Exercise

CalculateCostODecorations() is missing an "f" after the "O". It should be changed to "CalculateCostOfDecorations()".

Anonymous    Jan 01, 2008
Printed
Page 230
Pool puzzle solution Rowboat class

This block of code is missing a colon; public class Rowboat boat { public string rowTheBoat() { return "stroke natasha" } } should be public class Rowboat : boat { public string rowTheBoat() { return "stroke natasha" } }

Anonymous  May 30, 2008  Sep 01, 2008
Printed
Page 230
Pool puzzle solution Rowboat class

This block of code is missing a colon; public class Rowboat boat { public string rowTheBoat() { return "stroke natasha" } } should be: public class Rowboat : boat { public string rowTheBoat() { return "stroke natasha" } }

Anonymous    Sep 01, 2008
Printed
Page 230
In the pool puzzle solution, in the first blank, change “Boat” to “: Boat”

Anonymous    Sep 01, 2008
Printed
Page 233
Middle annotation on the left

Hi! This is Andrew (the author). We should make a minor change to clear up some confusion -- see this forum post: http://www.headfirstlabs.com/phpBB2/viewtopic.php?p=14142#14142 To fix this, add another annotation below this one, with an arrow pointing up at it: Keep an eye out for this slightly cryptic error. It means that your subclass didnít call the base constructor. (You might need to move the annotations around a little and redraw the arrow, but there's definitely enough room on the page for it.) The new annotation should read: The text of the error may be slightly different. It may say that your class "does not contain a constructor", or that it takes '4' arguments. That's the IDE telling you that you need to call the base constructor properly. Thanks!!

Anonymous  Oct 10, 2008  Sep 01, 2008
Printed
Page 233

Change the first sentence of the body text from this: If your class has a constructor, then any class that inherits from it must call that constructor. To this: If your class has constructors which take parameters, then any class that inherits from it must call one of those constructors. In the middle right-hand annotation, change “didn’t inherit the constructor properly” to “didn’t call the base constructor”

Anonymous    Sep 01, 2008
Printed
Page 235

In step 2, second bullet, change “subclasses only inherit” to “subclasses can only see” Add an annotation pointing to that bullet that says: “Later on, you’ll learn about the ‘protected’ keyword. A protected field is public to a subclass, but private to everyone else.”

Anonymous    Sep 01, 2008
Printed
Page 236
Code, comment for CalculateCost()

The comment still refers to the cost of beverages for the base CalculateCost() method. This comment probably belongs with the Dinnerparty override method. Remove this line of code from the bottom block of code on the page: // Each person costs $25 for food plus cost of beverages

Anonymous    Sep 01, 2008
Printed
Page 239/240
number2/bullet)star 6

On page number 239, Number 2, second sentence, it says "Once the queen's done assinging". Should be assigning. On page 240, sixth bullet, second line, it says "He keeps track of how many shifts are left in the current job.". It should be "in the ShiftsLeft".

Anonymous  Jun 11, 2008  Sep 01, 2008
Printed
Page 239
number 2

On page number 239, Number 2, second sentence, it says "Once the queen's done assinging". Should be assigning.

Anonymous    Sep 01, 2008
Printed
Page 240
Text in grey block on the bottom of the page

In the box where the head says "String.IsNullOrEmpty", the sentence goes a bit weird. "Since each bee stores its current job as a string, the way the worker knows whether or not he's not currently doing a job is to check if his CurrentJob property-". If his CurrentJob what?

Note from the Author or Editor:
Change the first sentence in the String.IsNullOrEmpty() box at the bottom of the page to: Each bee stores its current job as a string. So a worker can figure out if he's currently doing a job by checking his CurrentJob property – it'll be equal to an empty string if he’s waiting for his next job.

Anonymous  Jun 11, 2008  Sep 01, 2008
Printed
Page 240
Text in grey block on the bottom of the page

In the box where the head says "String.IsNullOrEmpty", the sentence goes a bit weird. "Since each bee stores its current job as a string, the way the worker knows whether or not he's not currently doing a job is to check if his CurrentJob property-". If his CurrentJob what? Change the first sentence in the “String.IsNullOrEmpty()” box at the bottom of the page to: Each bee stores its current job as a string. So a worker can figure out if he’s currently doing a job by checking his CurrentJob property – it’ll be equal to an empty string if he’s waiting for his next job.

Anonymous    Sep 01, 2008
Printed
Page 245
In the "Bee" class diagram, change "pblic" to "public"

Add an annotation pointing to the Bee class diagram: "Sometimes we'll show you return values and private members in class diagrams."

Anonymous    Jan 01, 2008
Printed
Page 245
"Add Existing Item" helper box

The box titled "Add Existing Item" leaves out the step to choose "Add Existing Item" from the menu. It says: - Right click on the project name in the new project's Solution Explorer in the IDE - Navigate to the old project's folder It is between these two steps that the "Choose 'Add Existing Item' from the menu" would be useful here. I was trying to follow the directions, not realizing that one of the key steps is the title of the box.

Note from the Author or Editor:
* In the third line in the box on the bottom of the page, change this: right-click on the project name in the new project's Solution Explorer in the IDE, navigate to ... to this: right-click on the project name in the new project's Solution Explorer in the IDE, select Add Existing Item from the menu, navigate to ...

Anonymous  May 23, 2008  Sep 01, 2008
Printed
Page 245

* "Add Existing Item" helper box; The box titled "Add Existing Item" leaves out the step to choose "Add Existing Item" from the menu. It says: - Right click on the project name in the new project's Solution Explorer in the IDE - Navigate to the old project's folder It is between these two steps that the "Choose 'Add Existing Item' from the menu" would be useful here. I was trying to follow the directions, not realizing that one of the key steps is the title of the box. * In the third line in the box on the bottom of the page, change this: right-click on the project name in the new project’s Solution Explorer in the IDE, navigate to ... to this: right-click on the project name in the new project’s Solution Explorer in the IDE, select ‘Add Existing Item’ from the menu, navigate to ...

Anonymous    Sep 01, 2008
Printed
Page 254
middle of the page

The error is in the illustration of the Queen object and two workers. The first worker object is labeled 'NectarCollan object' and the second one is labeled 'NectalCollar object'. Presumably both labels should say 'NectarCollector object'.

Anonymous  Oct 14, 2008 
Printed
Page 254-256

Pages 254-256 have been substantially revised since the first printing to enhance clarity and quality of learning. You can download a PDF containing the revised pages at: http://www.headfirstlabs.com/books/hfcsharp/hfcsharp_ch07_excerpt.pdf

Anonymous    Jan 01, 2008
Printed
Page 255

Change this: “So if you want your interface to require a field with a certain name and type, just use a property instead – it’ll accomplish the same thing.” To this: “So if you’ve got a problem that looks like it might be solved by adding a field to an interface, try using a property instead – the odds are that it’ll do what you’re looking for.”

Anonymous    Sep 01, 2008
Printed
Page 256
Add a No Dumb Questions to this page

Q: I still don't quite get how interfaces improve the beehive code. You'll still need to add a NectarStinger class, and it'll still have duplicate code... right? A: Interfaces aren't about preventing you from duplicating code. They're about letting you use one class in more than one situation. The goal is to create one worker bee class that can do two different jobs. You'll still need to create classes for them -- that's not the point. The point of the interfaces is that now you've got a way to have a class that does any number of jobs. Let's say you have a PatrolTheHive() method that takes a StingPatrol object and a CollectNectar() method that takes a NectarCollector object. But you don't want StingPatrol to inherit from NectarCollector or vice versa -- each class has public methods and properties that the other one shouldn't have. Now take a minute and try to think of a way to create one single class whose instances could be passed to both methods. Seriously, put the book down, take a minute and try to think up a way! How do you do it? Interfaces fix that problem. Now you can have create an IStingPatrol reference which -- and that reference can point to any object that implements IStingPatrol, no matter what the actual class is. It can point to a StingPatrol, or a NectarStinger, or even a totally unrelated object. If you've got an IStingPatrol reference pointing to an object, then you know you can use all of the methods and properties that are part of the IStingPatrol interface, regardless of the actual type of the object. But the interface is only part of the solution. You'll still need to create a new class that implements the interface, because it doesn't actually come with any code. Interfaces aren't about avoiding the creation of extra classes or avoiding duplicate code. They're about making one class that can do more than one job without relying on inheritance, because inheritance brings along a lot of extra baggage -- you'll have to inherit every method, property and field, not just the ones that have to do with the specific job. Can you think of ways that you could still avoid duplicating code while using an interface? You could create a separate class called Stinger or Proboscis to contain the code that's specific to stinging or collecting nectar. NectarStinger and NectarCollector could both create a private instance of Proboscis, and any time they need to collect nectar, they'd call its methods and set its properties.

Anonymous    Jan 01, 2008
Printed
Page 259
step 7

Change "Update your button so that the object initializer sets the FunnyThingIHave property, and the button calls" to "Update your button so that it calls"

Anonymous    Jan 01, 2008
Printed
Page 259
small typo at top right of page.

The second "accessor" is misspelled "accssor".

Anonymous    Jan 01, 2008
Printed
Page 263

The two code blocks should be in the same font -- reduce the font size for the top code block so it matches the bottom one.

Anonymous    Jan 01, 2008
Printed
Page 265
middle

thisCollector = workers[i] as INectarCollecter; this should be thisCollector = Bees[i] as INectarCollecter;

Anonymous    Sep 01, 2008
Printed
Page 266
SYP solution

#1 should be "0 and 6" Also, remove the second annotation ("All of these objects...")

Anonymous    Jan 01, 2008
Printed
Page 271
3rd paragraph

"the FunnyThingIHave set accessor should return" "set" should be "get"

Note from the Author or Editor:
In the first bullet for step #3, change "set" to "get" in the last sentence: The FunnyThingIHave get accessor should return the same thing.

Frederic Rabine  Apr 16, 2009 
Printed
Page 273

In the second bullet, change the second sentence to: You can’t mark a class private—unless that class lives inside another class, in which case it’s only available to instances of its container class. Then it’s private by default, and if you want it to be public you need to mark it public..

Anonymous    Sep 01, 2008
Printed
Page 273

Add the following sentence to the end of the fourth bullet: “You can combine this with protected – anything you mark protected internal can only be accessed from within the assembly or from a subclass. Add an annotation underneath the bottom bullet: “Sealed is a modifier, but it’s not an access modifier. That’s because it only affects inheritance – it doesn’t change the way class can be accessed.”

Anonymous    Sep 01, 2008
Printed
Page 274-275

- Turn this into a 1-2-3 spread (like pages 258-259)? There will be a (1) above "public interface IClown {", a (2) above "public class FunnyFunny : IClown {", a (3) on page 275 above "public class ScaryScary : ...", and a (4) above "private void button1_C

Anonymous    Jan 01, 2008
Printed
Page 275

Add a closing bracket to the bottom of the code under step 3. It should line up with the “p” in “public” in the first line of code.

Anonymous    Sep 01, 2008
Printed
Page 276
second answer

Add a sentence to the end of the answer, right after "store data by itself.": A property is a way to make something that looks like a field to other objects, but since it's really a method it doesn't actually store any data.

Anonymous    Jan 01, 2008
Printed
Page 277
class diagram

The arrows in the class diagram should be solid, not dotted.

Anonymous    Jan 01, 2008
Printed
Page 279
code at the bottom of the page

in the code under button1_Click, change "MarsMission" to "Mars" in the code under button2_Click, change "VenusMission" to "Venus"

Anonymous    Jan 01, 2008
Printed
Page 280
headline

Change the headline to: "Like we said, some classes should never be instantiated"

Anonymous    Jan 01, 2008
Printed
Page 281
1st paragraph

The third and fourth sentences of the paragraph don't fit with the rest of the paragraph. These sentences say, "So let's implement it! Once we do, the error will go away." These sentences are repeated in what I think is their correct place about 3/4 of the way down the page, after a screen shot of an error message.

Anonymous  Oct 15, 2008 
Printed
Page 281
change last sentence of body text to

So let's implement it! Once we do, the error will go away. Any time you extend an abstract class, you need to make sure that you override all of its abstract methods. Luckily, the IDE makes this job easier. Just type "public override" -- as soon as you press space, the IDE will display a drop-down box with a list of any methods that you can override. Select the SetMissionInfo method and fill it in:

Anonymous    Jan 01, 2008
Printed
Page 281
annotation, first line

Change "is just like an interface" to "is just like what you'd see in an interface"

Anonymous    Jan 01, 2008
Printed
Page 281
code at the bottom of the page

change "SetMissionInfo" to "public override SetMissionInfo" and add an annotation pointing to "override" that says: "When you inherit from an abstract class, you need to override all of its abstract methods."

Anonymous    Jan 01, 2008
Printed
Page 284
Last paragraph by Interface

Interface says "And that's just plan rude" - plan should be plain.

Anonymous  Jun 08, 2008  Sep 01, 2008
Printed
Page 284
Last paragraph by Interface

Interface says "And that's just plan rude" - plan should be plain.

Anonymous    Sep 01, 2008
Printed
Page 289
second paragraph, last line

Change "check it off the list" to "check it off the following list"

Anonymous    Jan 01, 2008
Printed
Page 291
code under step 6

Change both instances of "read-only DoorLocation" to "DoorLocation" Change both instances of "DoorDescription" to "read-only DoorDescription"

Anonymous    Jan 01, 2008
Printed
Page 298
step #3, second bullet point

(that'll be passed in by form) should be (that'll be passed in by the form)

Anonymous    Sep 01, 2008
Printed
Page 301
about two thirds of the way down the page -- the fourth annotation's arrow is pointing at it. Change this

while (hidden) { to this: while (!hidden) {

Anonymous    Jan 01, 2008
Printed
Page 301
13 lines from the bottom of the page -

Remove "0," from a line of code Change this: int rand = random.Next(0, myLocation.Exits.Length); to this: int rand = random.Next(myLocation.Exits.Length);

Anonymous    Sep 01, 2008
Printed
Page 312
fourth annotation on the right

Change: This shows "30", 10 * 3. to this: since Fetch has an index of 10, this statement sets score to 30.

Anonymous    Jan 01, 2008
Printed
Page 313

In the first answer, change “What you saw was a constructor” to “What you saw was a method”

Anonymous    Sep 01, 2008
Printed
Page 315
middle of page

error in the 09/08 errata !! http://oreilly.com/catalog/9780596514822/errata/9780596514822.0908 says: {315} middle of page; Console.WriteLine(cards[i].ToString()); should be Console.WriteLine(cards[i].Name()); it should be Console.WriteLine(cards[i].Name); No parentheses after Name

Note from the Author or Editor:
At the bottom of the block of code, change this: Console.WriteLine(cards[i].Name()); to this (removing () from after Name): Console.WriteLine(cards[i].Name);

Frederic Rabine  Apr 17, 2009 
Printed
Page 315
middle of page

Console.WriteLine(cards[i].ToString()); should be Console.WriteLine(cards[i].Name());

Anonymous    Sep 01, 2008
Printed
Page 317
Step 1 code listing

Current code states: List cards = new List<Card>(); Should be: List<Card> cards = new List<Card>();

Anonymous  Jun 03, 2008  Sep 01, 2008
Printed
Page 317

In step 1, change this: List cards = new List<Card>(); To this: List<Card> cards = new List<Card>();

Anonymous    Sep 01, 2008
Printed
Page 319
Sharpen Your Pencil

Swap "object o = myList[1];" and "int theSize = myList.Count;" so they're in the same order as on page 320.

Anonymous    Sep 01, 2008
Printed
Page 321
First block of code for adding new list

The list for addding new shoes is missing the "Shoe" object/class field right before ...Style.Sneakers it should read { Style = Shoe.Style.Sneakers, ...} Add an annotation in the white space in the box at in the lower right-hand corner of the page (you may need to widen the box a little to accommodate it): Remember, the Style enum isn’t inside the Shoe class, so it’s just “Style.Sneakers”, not “Shoe.Style.Sneakers”.

Anonymous    Sep 01, 2008
Printed
Page 322
first annotation, last line

Change "and limit the type" to "which limits its members to that type"

Anonymous    Jan 01, 2008
Printed
Page 322

In bullet #5, change “type parameter” to “type argument” Change this code: List name = new List<T>(); To this: List<T> name = new List<T>();

Anonymous    Sep 01, 2008
Printed
Page 330
first paragraph, second line

Change "to build your own sorting logic" to "to build a separate class to help the List sort out its members"

Anonymous    Jan 01, 2008
Printed
Page 331
remove the top annotation ("Console applications that...")

Anonymous    Jan 01, 2008
Printed
Page 331
#2, second paragraph, first line

Change "box underneath it, when you" to "box underneath it. When you"

Anonymous    Jan 01, 2008
Printed
Page 335
first annotation

The annotation should point to "dic-tion-ar-y" and not the text underneath it.

Anonymous    Jan 01, 2008
Printed
Page 335
second annotation on the right pointing to TKey and TValue

Change "The first item" to "These represent types. The first type"

Anonymous    Jan 01, 2008
Printed
Page 339
4th line of body text at the top of the page

change "obects" to "objects"

Anonymous    Jan 01, 2008
Printed
Page 348
1st line of comments in 2nd AskForACard() method

// Ask the other players for a value. first should be: // Ask the other players for a value. First

Anonymous    Sep 01, 2008
Printed
Page 349
1st block of code

Full details: http://www.headfirstlabs.com/phpBB2/viewtopic.php?t=6458

Note from the Author or Editor:
Add an annotation pointing to the code under step 6: We used a partial class to add this static method to Card to make it easy for you to see what's going on. But you don't need to use a partial class -- if you want, you can just add it straight into the existing Card class.

Anonymous  Jul 01, 2008  Sep 01, 2008
Printed
Page 349
1st block of code

Full details: http://www.headfirstlabs.com/phpBB2/viewtopic.php?t=6458 Add an annotation pointing to the code under step 6: We used a partial class to add this static method to Card to make it easy for you to see what’s going on. But you don’t need to use a partial class -- if you want, you can just add it straight into the existing Card class.

Anonymous    Sep 01, 2008
Printed
Page 350
under the Deal() method,

Page 350, under the Deal() method, currently reads: "call each player's PullOutBooks() method." It should read: "call the Game class's PullOutBooks() method, described beneath."

Note from the Author or Editor:
About halfway down the page, change this line: // foreach loop to call each playerís PullOutBooks() method. to this // foreach loop to call the PullOutBooks() method for each player.

Anonymous  Mar 16, 2009 
Printed
Page 367
2nd paragraph

The text in my book says: "...Set the BackColor Poperty of each to Color.Transparent (If you use the Properties window to set the property, just type it into the BackColor row)" When I type "Color.Transparent" into the BackColor row, I get the following error from Visual Studio 2008 Express SP1: "Color.Transparent is not a valid value for Int32." It seems to work as expected if I leave out "Color.", and just type "Transparent".

Note from the Author or Editor:
In the second edition, this is on page 189. In the upper right-hand corner annotation, second line, change "to Color.Transparent" to "to Transparent".

None  Feb 21, 2010 
Printed
Page 367
In the second paragraph, change "Transparent" to "Color.Transparent (if you use the Properties window to set the propery, just type it into the BackColor row)."

Add an annotation in the top right corner pointing at the screenshot: "You can set a PictureBox's BackColor property to Color.Transparent to let the form's background picture or color show through any transparent pixels in the picture."

Anonymous    Jan 01, 2008
Printed
Page 369
Add an annotation in the bottom left-hand corner pointing to the last line of code: "All the other weapons' borders should be turned off."

Anonymous    Jan 01, 2008
Printed
Page 369
Bottom diagram (How the inventory scroll works)

The label on the top arrow from "Inventory Icon Clicked" Form object image to Game object image is missing a right parenthesis on the "if" statement. Is: if (game.CheckPlayerInventory("Bow") { Should be if (game.CheckPlayerInventory("Bow")) { =================================== The label on the bottom arrow between the same two object images uses curly braces on the method call, not parentheses. Is: game.Equip{"Bow"}; Should be game.Equip("Bow");

Anonymous  Jul 11, 2008  Sep 01, 2008
Printed
Page 370
top annotation

Change "the Rectangle class" to "Rectangle and Point"

Anonymous    Jan 01, 2008
Printed
Page 372
Add an annotation pointing to the Mover box: "We added return values and parameters to this class diagram to make it easier for you to see what's going on."

Anonymous    Jan 01, 2008
Printed
Page 374
near the vertical center of the page

The printing date of my copy is 04/08. On page 374 near the vertical center of the page, a line of code reads: "public Player(Game game, Point Location);" There should not be a semicolon at the end of the line.

Note from the Author or Editor:
In this line (middle of page): public Player(Game game, Point location); remove the semicolon from the end of the line.

Anonymous  Sep 03, 2008 
Printed
Page 376
Change the annotation in the middle from "The NearPlayer() method uses the Mover.Nearby() static method to figure out if the enemy is near the player." to "The Enemy class inherited the Nearby() method from mover, which it can use to figure out whether it

Anonymous    Jan 01, 2008
Printed
Page 378
Code near the bottom of the page

Hi! This is Andrew, the author. This is a fix to a typo that was pointed out in the forum: http://www.headfirstlabs.com/phpBB2/viewtopic.php?p=14307#14307 On p378, change this line of code: target = Move(direction, target, game.Boundaries); to this: target = Move(direction, game.Boundaries); Thanks!

Anonymous  Oct 25, 2008 
Printed
Page 378
In the code, 10 lines from the bottom of the page

Add an annotation that points to this line of code: "if (Nearby(enemy.Location, target, radius)) {" it should say: "The Nearby() method in the Mover class only takes two parameters, a Point and an int, and it compares the Point to the Mover field location. You'll need to add an overloaded Nearby() that's almost identical, except that it takes three parameters, two Points and a distance, which compares the first Point to the second Point (instead of location)."

Anonymous    Jan 01, 2008
Printed
Page 383
bullet #4

Check use the Game .... should be Check the Game... 5th Point Text; Text is identical to 1st point text on previous page, and should clearly not be. In step 4, change the first few words to: check the Game object’s In step 5, change the body text to this: The rest of the method does three things. First it checks to see if the player’s already picked up the weapon in the room, so it knows whether or not to display it. Then it checks to see if the player died. And finally, it checks to see if the player’s defeated all of the enemies. If he has, then the player advances to the next level.

Anonymous    Sep 01, 2008
Printed
Page 384
second paragraph, second line:

change "and add way" to "and add a way" third paragraph, second to last last line: change "user-friendly ending -- maybe" to "user-friendly ending? Maybe you can"

Anonymous    Jan 01, 2008
Printed
Page 385
thought bubble

Move the underline so that it's under "am"

Anonymous    Jan 01, 2008
Printed
Page 387
In step 1, change “text or binary data” to “your data”

Anonymous    Sep 01, 2008
Printed
Page 395
second half

private variables are supposed to be lowercase, yet you have "private Streamwriter Writer" And, seriously guys -- what was the idea with those bizarre and totally irrelevant method and variable names? What does Fargo have to do with directions? what does Idaho (or Fargo, for that matter) have to do with anything related to writing a pizza order?

Note from the Author or Editor:
Add "writer" and "reader" (with lowercase 'w' and 'r') to the pool. On page 395 in the last block of code, change all occurrences of "Reader" to "reader": public class Party { private ____________ reader; public Party(____________ reader) { __________.reader = reader; } public void HowMuch(__________ q) { q._________(reader._________()); reader.__________(); } } and in the solution on page 396, change all occurrences of "Reader" to "reader", and all occurrences of "Writer" to writer": public class Pizza { private StreamWriter writer; public Pizza(StreamWriter writer) { this.writer = writer; } public void Idaho(Pineapple.Fargo f) { writer.WriteLine(f.ToString()); writer.Close(); } } public class Party { private StreamReader reader; public Party(StreamReader reader) { this.reader = reader; } public void HowMuch(StreamWriter q) { q.WriteLine(reader.ReadLine()); reader.Close(); } } Finally, add an annotation in the lower right-hand corner of page 396: Class names like Pizza, Party and Pineapple have nothing to do with directions like North and East. You wouldn't use them in a real-life program... but if we gave these classes intuitive names, it'd make for a pretty boring puzzle!

Michael  Mar 20, 2009 
Printed
Page 398;399
Third comment

Page 398, third comment; "The initialDirectory propery" should be "The initialDirectory property" Page 399; The second comment on the left hand side of the page says "..and opens the folder specified in the InitialFolder property". But there is no InitialFolder in the code, there's an InitialDirectory.

Note from the Author or Editor:
(398) middle annotation; propery should be property (399) The second comment on the left hand side of the page says "..and opens the folder specified in the InitialFolder property". But there is no InitialFolder in the code, there's an InitialDirectory. In the bottom left-hand annotation, change InitialFolder to InitialDirectory.

Anonymous  Jun 04, 2008  Sep 01, 2008
Printed
Page 398
middle annotation

propery should be property

Anonymous    Sep 01, 2008
Printed
Page 399
first paragraph, first sentence

Change "An OpenFileDialog box object" to "An OpenFileDialog object"

Anonymous    Jan 01, 2008
Printed
Page 399
The second comment on the left hand side of the page says "..and opens the folder specified in the InitialFolder property". But there is no InitialFolder in the code, there's an InitialDirectory.

In the bottom left-hand annotation, change InitialFolder to InitialDirectory.

Anonymous    Sep 01, 2008
Printed
Page 406
fifth annotation that starts "In this case"

Change "the Log stream, so the Dispose()" to "pointed to by sw -- which was declared in the using statement, so the Dispose()"

Anonymous    Jan 01, 2008
Printed
Page 406
bottom block of code, first two lines that start with "using"

Remove the semicolons at the end of these two lines and add an extra closing parenthesis at the end of each line. The code should be: using (StreamReader reader = new StreamReader(“secret_plan.txt”)) using (StreamWriter writer = new StreamReader(“email.txt”))

Anonymous    Jan 01, 2008
Printed
Page 413

Change the leftmost annotation from this: Every case must end with “break;”. To this: Every case ends with “break;” so C# knows where one case ends and the next begins. (You can also end a case with “return” – the program will compile as long as there’s no way for one case to “fall through” to the next one.)

Anonymous    Sep 01, 2008
Printed
Page 417
bullet #3

"you can go back to fhe file....." should be "you can go back to the file...."

Anonymous    Sep 01, 2008
Printed
Page 418
brain barbell

List<Passangers>object should be List<Passengers>object In the curved text under the bottom circle in the box, change “List<Passangers> object” to “List<Passengers> object”.

Anonymous    Sep 01, 2008
Printed
Page 421
- first line of code ("[Serializable"]) under step #1

Add an annotation pointing to [Serializable]: You need to add this attribute to the top of any class in order to serialize it.

Anonymous    Jan 01, 2008
Printed
Page 421
third-to-last line of code

Remove the semicolon from this line: };

Anonymous    Jan 01, 2008
Printed
Page 421
- code

Change both instances of "Joe" to "joe" -- not capitalized also, in the last block of code, change both instances of "bf" to "formatter": BinaryFormatter formatter = new BinaryFormatter(); joe = (Guy)formatter.Deserialize(input); In the second-to-last line of code, change "CheckGuys();" to "UpdateForm();" Also, the screenshot is incorrect, and has been replaced in this reprint.

Anonymous    Jan 01, 2008
Printed
Page 422
step 3, second line

change PrintCards to DealCards

Anonymous    Jan 01, 2008
Printed
Page 422
code, fifth line from the bottom

change "DeckToDeal.Deal();" to "DeckToDeal.Deal(0);"

Anonymous    Jan 01, 2008
Printed
Page 423
step 4, second-to-last line o code

Swap the line of code that starts "DealCards(..." with the preceding line so it's before the closing curly brace, and indent it by another two spaces.

Anonymous    Jan 01, 2008
Printed
Page 423
second annotation

The arrow for this annotation is slightly misaligned -- it needs to point to "(Deck)"

Anonymous    Jan 01, 2008
Printed
Page 423
bullet #4

in button2_click event handler, DealCards(....) should be outside of the using block. In last four lines of code under step #4 need, the “DealCards...” line needs to be moved below the second-to-last bracket and unindented by two spaces: Deck deckFromFile = (Deck)bf.Deserialize(input); } DealCards(deckFromFile, “What I read from the file”); }

Anonymous    Sep 01, 2008
Printed
Page 424
Behind the Scenes box, second line of text at the top

Make "unicode" uppercase - "Unicode"

Anonymous    Jan 01, 2008
Printed
Page 425
Step number 3

You forgot to tell us the 4th Hebrew letter, U+05E9, as you're telling us what to choose on the character map. You only mention it as an afterthought at the bottom of the page.

Note from the Author or Editor:
In the first line of text for step #3, change this: "double-click on the Shin character" to this" "double-click on the Shin character, which has the code U+05E9"

Michael  Mar 24, 2009 
Printed
Page 425
step 3, first paragraph, last line

change: then paste the letters over "Eureka!" so it looks like this: to: then paste the letters over "Eureka!" and add the Encoding.Unicode parameter, so it looks like this:

Anonymous    Jan 01, 2008
Printed
Page 425
step 3, line of code

Add a third parameter, Encoding.Unicode -- it should look like this: File.WriteAllText("eureka.txt", "[HEBREW CHARACTERS HERE]", Encoding.Unicode);

Anonymous    Jan 01, 2008
Printed
Page 430
second block of code

in the first line, change 227 to 218 in the second line, change 275 to 266

Anonymous    Jan 01, 2008
Printed
Page 433

Add an annotation pointing to “ReadBlock()” in the top paragraph: The reason the method’s called “ReadBlock()” is that when you call it, it “blocks” (which means it keeps executing and doesn’t return to your program) until it’s either read all the characters you asked for or run out of data to read.

Anonymous    Sep 01, 2008
Printed
Page 433

Add an annotation (without an arrow) to the space in the bottom left-hand corner: The hex dumper works just fine for text files. But there’s a problem. Use File.WriteAllBytes() to write an array of bytes with values over 127 to a file and then run it through your dumper. Uh-oh – they’re all read in as “fd”! That’s because StreamReader is built to read text files, which only contain bytes with values under 128. Here’s a bonus exercise: See if you can figure out how to use the BinaryReader class to fix the problem!

Anonymous    Sep 01, 2008
Printed
Page 434
last answer, sixth line

change "add a third parameter" to "change the third parameter"

Anonymous    Jan 01, 2008
Printed
Page 434

In the sidebar in the lower-right corner, change the text “using two bytes each.” to “using two or more bytes each.” Add an annotation at the bottom of the page pointing to the sidebar: “This encoding is called UTF-8, which .NET uses by default. You can tell File.WriteAllText() to use a different encoding by passing it a different Encoding object. You can learn more about Unicode encodings at http://unicode.org.”

Anonymous    Sep 01, 2008
Printed
Page 436
seventh line of code

change "save_Click" to "open_Click"

Anonymous    Jan 01, 2008
Printed
Page 448

In the title bar of the third class box on the bottom, change “OverFlowException” to “OverflowException”

Anonymous    Sep 01, 2008
Printed
Page 448
Second paragraph

The text states: "The Exception class has a couple of useful members. The Message properties stores an easy-to-read message..." It should be: "... The Message property ..." as there's only one of them. In the first line of the second paragraph, change “Message properties” to “Message property”.

Anonymous    Sep 01, 2008
Printed
Page 462
Second Answer, first sentence.

"Whenever you program throws an exception, the runtime environment will search through your code looking for a catch block to that matches it." Either that "to " should not be there or it should say "... to match it". In the second answer (the top two lines of the second column), change: for a catch block to that matches it to: for a catch block that matches it

Anonymous    Sep 01, 2008
Printed
Page 465
bottom right-hand corner picture

The "EX" label on the Exception object should have a white text background, not transparent, so it looks white and not grey

Anonymous    Jan 01, 2008
Printed
Page 468
third line ("throw new ArgumentNullException();")

change "ArgumentNullException();" to "ArgumentException();" and add an annotation pointing to it: Your methods can throw this exception if they get invalid or unexpected values in their parameters.

Anonymous    Jan 01, 2008
Printed
Page 468
Code example, try block in consumeHoney_Click method

The button click handler creates a HoneyDeliverySystem object called delivery and then tries to call a FeedHoneyToEggs method without specifying the parent object's name: FeedHoneyToEggs()" In the bottom block of code, eight lines from the bottom, change: FeedHoneyToEggs(); To: delivery.FeedHoneyToEggs();

Anonymous    Sep 01, 2008
Printed
Page 471
bottom right-hand corner box

There should be no line break between "new" and "YourClass();"

Anonymous    Jan 01, 2008
Printed
Page 472
sixth annotation

change "You'll often see one using statement inside of another." to "You'll see nested using statements like this when you need to declare two IDisposable references in the same block of code."

Anonymous    Jan 01, 2008
Printed
Page 472
seventh annotation

the arrow is pointing to an underscore that's misaligned -- it should be under "Log"

Anonymous    Jan 01, 2008
Printed
Page 472
Fifth annotation

Surely the underline is misplaced and should be under "must", not over it? Third paragraph, second sentence; The text states: "First, let's use a built-in object that implements IDisposable, Stream." Change to: "First, let's use built-in object Stream, which implements IDisposable."

Anonymous    Sep 01, 2008
Printed
Page 473
fourth answer, last paragraph

change "SomethingRisky()" to "DoSomethingRisky()"

Anonymous    Jan 01, 2008
Printed
Page 474
- second paragraph, first line

change "Take a look at the DivisorCalculator" to "Take a look at this Calculator class"

Anonymous    Jan 01, 2008
Printed
Page 484
first annotation that starts "When the ball gets hit"

change BallHasBeenHit() to OnBallInPlay()

Anonymous    Jan 01, 2008
Printed
Page 485
Annotation to Umpire object

The note states: "The umpire checks every ball ... and monitor what happens." This should be "... umpires check ..." or "... monitors ...". In the last line of the annotation pointing to the Umpire object, change “monitor” to “monitors”

Anonymous    Sep 01, 2008
Printed
Page 485
Final paragraph, 2nd and 3rd sentences

There is inconsistent use of singular/plural in the last paragraph: "... So you write code to raise an event, and then you write code to handle those events ... Then, whenever an event is raised, your handlers kick into action." To be consistent, this should be: "... you write code to raise an event, and ... write code to handle that event" and "... your handler kicks into action." In the last paragraph on the page, change “your handlers kick” to “your handler kicks”

Anonymous    Sep 01, 2008
Printed
Page 487
fourth annotation that starts "Here's what each object"

change this annotation to: Here's what each object that handles the event gets to work with. It also gets a reference to the object that raised the event.

Anonymous    Jan 01, 2008
Printed
Page 488
bottom annotation starting with "When you use EventHandler..."

Add another sentence to the end of this annotation: sender is a reference to the object that raised the event, and e is a reference to an EventArgs object.

Anonymous    Jan 01, 2008
Printed
Page 496
Exercise Solution, declaration of BallEventArgs class

The definition of the BallEventArgs class is missing its inheritance from the EventArgs base class. It should look like this: "public class BallEventArgs : EventArgs { ... " This was correct in the original, type this in, version on p492, so it's only a minor mistake, almost a typo. Change the boldfaced line of code in the middle of the page from this: public class BallEventArgs { to this: public class BallEventArgs : EventArgs {

Anonymous    Sep 01, 2008
Printed
Page 498
first annotation

remove the word "pre-made" from the second line of the annotation

Anonymous    Jan 01, 2008
Printed
Page 498
bullet #2

messagebox.show should say "You just clicked on the form" first annotation; "You can see all of the events for a control by click on it..." should be "...clicking on it...."

Anonymous    Sep 01, 2008
Printed
Page 498
Step 1

The text for Step 1 states: "Create a new Windows Application project. Bring up the form, and go to the Properties window." Now, it is not clear what "bring up the form" means. When you create a new project, the IDE displays the Form1.cs [Design] tab but the Properties window shows the solution (e.g. "Chapter 11 Program 2") Project Properties. It is not clear that you have to click on the Form1.cs [Design] **tab** to switch to the desired Form1 ... properties. Change “Bring up the form, and go to the Properties window.” to “Go to the Properties window for the form.”

Anonymous    Sep 01, 2008
Printed
Page 498
First annotation

The text for note 1 states: "You can see all of the [pre-made] events for a control by click on it and then click on this events button in the properities window." "pre-made" has already been deleted in an earlier update. The English is a bit strained, but the simplest way to fix it is to change the "click"s to "clicking"s. It would also be sensible to correct the spelling and Capitalization of "properities window" to "Properties window" while you're at it. In the top right annotation, change “You can see all of the events for a control by click on it” To “You can see all of the events for a control: just click on it”

Anonymous    Sep 01, 2008
Printed
Page 499

Add an annotation pointing to the code under step 6: "When you click these buttons, they chain different event handlers onto the form's Click event." Then add an annotation under it, pointing up at it: "That means you won't see anything when you click the buttons! You'll need to click on the form, because the buttons change the form's behavior by modifying its Click event."

Anonymous    Sep 01, 2008
Printed
Page 502
step 1, first paragraph, second line

Change "AddSecretIngredient.cs" to "GetSecretIngredient.cs"

Anonymous    Jan 01, 2008
Printed
Page 506
third paragraph

change both instances of "ListenForClues()" to "treasure_RunForCover()"

Anonymous    Jan 01, 2008
Printed
Page 506
Pool Puzzle Solution, 3rd line of code

in the line: "this.Load += new EventHandler(Minivan);" "Load" is already highlighted in the solution but "Minivan" is not. As "Minivan" is one of the items that had to be added from the Pool, it should also be highlighted. By the way, "Van", "Car", and "Tricycle" are possible alternative names for the "Minivan" event handler. There's nothing to prevent them being used in the Pool Puzzle, provided whichever name is chosen is used in both the Form1() constructor and for the 4th event handler. Perhaps "Tricycle" should be replaced by "Bicycle", and "Van" or "Car" replaced by "Towtruck". The third of these could be removed from the Pool as it isn't really necessary, except as a source of confusion. In the pool puzzle on page 504, change the third line of code from this: this.______ += new EventHandler(____________); to this: this.______ += new EventHandler(Minivan);

Anonymous    Sep 01, 2008
Printed
Page 509
fifth bullet point

Change "You chain several" to "You can chain several"

Anonymous    Jan 01, 2008
Printed
Page 510
first answer, second paragraph, last line

The last word of the last sentence is cut off -- add the word "constructor."

Anonymous    Jan 01, 2008
Printed
Page 510
there are no Dumb Questions, Annotation 2

The last note states: "The first one you'll learn about is called the "Publisher-Subscriber" pattern." I started reading HFDP before HFC#... and actually, it's called the "Observer" pattern! In the bottom right-hand annotation, change this: the “Publisher-Subscriber” pattern, To this: the “Observer” (or “Publisher-Subscriber”) pattern,

Anonymous    Sep 01, 2008
Printed
Page 510
there are no Dumb Questions, Answer 3

The fifth sentence states: "So if you mark an event private, then other instances if the same class can subscribe to it." That "... if the same class" should be "... of the same class".

Anonymous    Sep 01, 2008
Printed
Page 511
second italicized paragraph near the middle of the page

change both instances of "ListenForClues()" to "treasure_RunForCover()"

Anonymous    Jan 01, 2008
Printed
Page 520
bottom paragraph

Add an annotation at the bottom of the page pointing up at the bottom paragraph: Since this simulator will be animated, we'll be drawing it frame by frame. We'll use the words "frame," "cycle," and "turn" interchangeably.

Anonymous    Jan 01, 2008
Printed
Page 521
second annotation

Remove the asterisk from the beginning of the annotation. Change "We used" to "You'll use".

Anonymous    Jan 01, 2008
Printed
Page 521
Annotation to Step 4

The note states: "*Hint: We used NectarGatheredPerTurn, nectar, and NectarHarvested in this method, but nothing else." The variable for the flower's nectar is called "Nectar" (on p520). I'm wondering whether the list style "first, second, and third" has been used previously in this book. I would have thought it should be "first, second and third" - i.e. no final comma - but maybe that's just me! In second line of the annotation under step 4, capitalize “Nectar”

Anonymous    Sep 01, 2008
Printed
Page 524
second line

Change "its" to "it's"

Anonymous    Jan 01, 2008
Printed
Page 529
Hive class diagram

getLocation should be GetLocation In the bottom line in the class diagram box in the upper right-hand corner of the page, change “getLocation” to “GetLocation”

Anonymous    Sep 01, 2008
Printed
Page 529
Step 3, second sentence

In Step 1, the skeleton code for the Hive class states "... locations should be private, ...". Step 3 says the GetLocation() method should "look up that string in the Locations dictionary, ...". I think "Locations" should be treated as a variable name - in other words with correct (lower) case and in fixed-width font. In the second line of step 3, change “Locations” to “locations” and put it in the Courier code font

Anonymous    Sep 01, 2008
Printed
Page 536
first two annotations

Anonymous    Jan 01, 2008
Printed
Page 536
World constructor

There should be a line to instantiate the Hive variable but it is missing. Change the body text at the top of the page to this: The World class is actually one of the simpler classes in our simulator. Here’s a starting point for the code. But if you look closely, you’ll notice that it’s missing a few things (which you’ll add in just a minute).

Anonymous    Sep 01, 2008
Printed
Page 537
second annotation

The annotations and their arrows are misaligned. They need to be shifted down.

Anonymous    Jan 01, 2008
Printed
Page 537
second answer on bottom of page

"..beginning of a list of five bees..." should be "..beginning of a list of five flowers..." In the third line of the second answer, change “bees” to “flowers”

Anonymous    Sep 01, 2008
Printed
Page 538
step 1, second line

Change "hive and world in the constructor" to "hive and world as parameters to its constructor"

Anonymous    Jan 01, 2008
Printed
Page 538
step 5, first line

Change "The World class keeps up with all the bees" to "The World class uses a List of Bee objects to keep track of all the bees"

Anonymous    Jan 01, 2008
Printed
Page 539
second question

Change "Point object" to "Point"

Anonymous    Jan 01, 2008
Printed
Page 539
last answer

Add this after the first sentence: "Plus, it'll come in handy when we do the animation."

Anonymous    Jan 01, 2008
Printed
Page 539
final answer

"No reason reinvent the wheel..." should be "No reason to reinvent the wheel..."

Anonymous    Sep 01, 2008
Printed
Page 539
There are no Dumb Questions, Answer 3

Sentence 2 starts: "However, just becase .NET uses them that way, ..." That should be "... because ...". In the third line of the last answer, change “becase” to “because”

Anonymous    Sep 01, 2008
Printed
Page 540
first annotation

Change "local variables" to "private fields"

Anonymous    Jan 01, 2008
Printed
Page 540
second annotation that starts "More basic code...", second line

Change "assign it locally" to "set a private field"

Anonymous    Jan 01, 2008
Printed
Page 541
bottom

The annotations are overlapping the box

Anonymous    Jan 01, 2008
Printed
Page 544
first annotation in the left

Change "dropdown that appears on the form" to "dropdown that appears on the ToolStrip when you're in the form designer"

Anonymous    Jan 01, 2008
Printed
Page 544
second annotation on the left

Change "Use the dropdown" to "Use the dropdown that appears on the StatusStrip in the designer"

Anonymous    Jan 01, 2008
Printed
Page 544
first annotation on the right that starts "Each of these labels"

Add a new annotation above this one with an arrow pointing down at it. It should say: The labels in the right-hand column will show the stats. Name them "Bees", "Flowers", "HoneyInHive", etc.

Anonymous    Jan 01, 2008
Printed
Page 545
UpdateStats method

There should be an annotation reminding us to add a line to the Form1 to create the framesRun variable, if that's the best place for it. Also, what type is it? I've assumed double, but probably an int would do unless this is going to be a very long run...

Note from the Author or Editor:
Change the middle annotation on the left from this: "Add this method into Form1." to this: "You'll need to add this method to Form1. You'll be adding an int called framesRun in a minute..."

Anonymous  May 27, 2008 
Printed
Page 547

Add the "Behind the Scenes" picture (like on p576) to the upper right-hand corner of the page.

Anonymous    Jan 01, 2008
Printed
Page 548
top right

In the second-to-last line of the “DateTime & TimeSpan” box, change “obect” to “object”

Anonymous    Sep 01, 2008
Printed
Page 549
exercise box

Add another annotation underneath the first one that says: "Just double-click on a ToolStrip button in the designer to make the IDE add its event handler, just like a normal button."

Anonymous    Jan 01, 2008
Printed
Page 556
middle

In the second line of body text, change Langauge to Language

Anonymous    Sep 01, 2008
Printed
Page 560

move the arrow from the second-to-last annotation a little to the right – it’s overlapping the code.

Anonymous    Sep 01, 2008
Printed
Page 561
left-hand annotation

The annotation is pointing to an underline, but the underline is misaligned--it needs to be moved up

Anonymous    Jan 01, 2008
Printed
Page 561
middle

When reading in the file the variable name should be input as opposed to output. In lines 15 to 17 of the code, the word “output” appears three times – change it to “input”. using (Stream input = File.OpenRead(openDialog.FileName)) { world = (World)bf.Deserialize(input); framesRun = (int)bf.Deserialize(input); Then change the annotation pointing to the bottom to lines to: Here’s where we deserialize the world and the number of frames run from the file

Anonymous    Sep 01, 2008
Printed
Page 566
first line

Change "great simulator" to "cool simulator"

Anonymous    Jan 01, 2008
Printed
Page 566
step 2

Change "We'll add a Print button to the stats window" to "We'll make the Print button in the stats window work" Change the two sentences underneath that to: "The stats window has working Open and Save buttons, but the Print button doesn't work yet. We'll be able to reuse a lot of the graphics code to get the Print button on the ToolStrip to print an info page about what's going on.

Anonymous    Jan 01, 2008
Printed
Page 572
Sharpen Your Pencil, explanation for fourth code item

The Solution states:- "This loop searches through all the controls on the form until it finds a label with the text "Bobby". Once it finds the label, it removes it from the form." This is not correct. What the loop does is this:- The loop searches through all the controls on the form. If it finds a label with the text "Bobby", it remembers it (but it doesn't stop looking). After the loop exits, if a label was found (controlToRemove is no longer null), it is removed from the form. If not, a null reference exception is thrown. If there was a break to get out of the loop once a control was found, or the loop was executed backwards in the manner of the bees, then it would be possible to remove one or more controls. As written, it is only possible to remove the last one.

Note from the Author or Editor:
Add an annotation in the space above the fourth answer pointing down at it: What happens there's no control named 'Bobby' in the Controls collection?

Anonymous  Jun 27, 2008  Sep 01, 2008
Printed
Page 572
Sharpen Your Pencil, explanation for fourth code item

The Solution states:- "This loop searches through all the controls on the form until it finds a label with the text "Bobby". Once it finds the label, it removes it from the form." This is not correct. What the loop does is this:- The loop searches through all the controls on the form. If it finds a label with the text "Bobby", it remembers it (but it doesn't stop looking). After the loop exits, if a label was found (controlToRemove is no longer null), it is removed from the form. If not, a null reference exception is thrown. If there was a break to get out of the loop once a control was found, or the loop was executed backwards in the manner of the bees, then it would be possible to remove one or more controls. As written, it is only possible to remove the last one. Add an annotation in the space above the fourth answer pointing down at it: What happens there’s no control named “Bobby” in the Controls collection?

Anonymous    Sep 01, 2008
Printed
Page 574
screenshot

Add an annotation pointing to the screenshot that says: "Double-click on Resources.resx to bring up the Resources page."

Anonymous    Jan 01, 2008
Printed
Page 575
step 3

add an annotation pointing to the line of code under step 3 that says: "When the program's running, each picture is stored in memory as a Bitmap object."

Anonymous    Jan 01, 2008
Printed
Page 576
step 2

change "and and" to "add and"

Anonymous    Jan 01, 2008
Printed
Page 576
behind the scenes box, last paragraph

Change "you see in the form's Properties window" to "you see in the Properties window for any control"

Anonymous    Jan 01, 2008
Printed
Page 577
whole page

Bullet point 3 is repeated Replace the three lines of the body text under step 3 with this (“animationTimer.Dispose()” should be in Courier code font): Change the new Dispose() method that the IDE added for you so that it calls animationTimer.Dispose().

Anonymous    Sep 01, 2008
Printed
Page 582
annotation that starts "Set the form's BackgroundImage"

change "inside hive picture." to "inside hive picture, and its BackgroundImageLayout property to Stretch."

Anonymous    Jan 01, 2008
Printed
Page 582
MouseClick Event Handler code

The code given shows the MouseClick EventHandler as being in the main form - Form1_MouseClick(). Surely it should be in the FieldForm - FieldForm_MouseClick() (and the HiveForm)? Maybe there should be an annotation saying to make sure the event handler is added to the actual form, not a PictureBox or the co-ordinates will be PictureBox-control-relative.

Note from the Author or Editor:
In the first line of code in the middle of the page, change Form1_MouseClick to FieldForm_MouseClick

Anonymous  Jun 28, 2008  Sep 01, 2008
Printed
Page 582
MouseClick Event Handler code

The code given shows the MouseClick EventHandler as being in the main form - Form1_MouseClick(). Should it be in the FieldForm - FieldForm_MouseClick() (and the HiveForm)? Maybe there should be an annotation saying to make sure the event handler is added to the actual form, not a PictureBox or the co-ordinates will be PictureBox-control-relative. In the first line of code in the middle of the page, change “Form1_MouseClick” to “FieldForm_MouseClick”

Anonymous    Sep 01, 2008
Printed
Page 583
top annotation

"...other class needs to update to any..." should be "...other class needs to update any..." In the fourth line of the upper right-hand annotation, change “to any of its properties” to “any of its properties”.

Anonymous    Sep 01, 2008
Printed
Page 585
MoveBeeFromHiveToField method

why does this need a Bee parameter? Remove “, Bee bee” from the declaration of the MoveBeeFromHiveToField method, so it looks like this: private void MoveBeeFromHiveToField(BeeControl beeControl) {

Anonymous    Sep 01, 2008
Printed
Page 589
Step 1

the constants to increase bees is in the Hive class, not the World class bullet #3; "of of" bullet #3; "bee image are sometimes" should be "bee images are sometimes" In the second line under step 1, change “World class” to “Hive class” In the fourth line under step 3, change “areas of of the bee” to “areas of the bee” In the last line under step 4, change “the bee image are sometimes” to “the bee images are sometimes”

Anonymous    Sep 01, 2008
Printed
Page 591
step 2, first line

change "an array of four of them" to "in this case, an array of four of them"

Anonymous    Jan 01, 2008
Printed
Page 591
block of code under step 2

Add an annotation pointing at this code that says: "These lines take each of the Bitmap objects that store the bee pictures and shrink them down using the ResizeImage() method we wrote."

Anonymous    Jan 01, 2008
Printed
Page 593
last paragraph, last line

Change "trickier..." to "slower..."

Anonymous    Jan 01, 2008
Printed
Page 602
Step 2 code example

Step 1 says to double-click on Paint in the Form's Events list. This produces an Event Handler called Form1_Paint. Step 2 shows this code but now it's called UserControl1_Paint. Surely it should (still) be Form1_Paint?

Note from the Author or Editor:
In the first line of code under step 2, change UserControl1_Paint to Form1_Paint

Anonymous  Jul 08, 2008  Sep 01, 2008
Printed
Page 602
Step 3 first sentence

Step 3 says:- "Add the new DrawBees() method from the previous page into your new user control." Firstly, the method from the previous page is called DrawBee () not DrawBees. Secondly, the last project that included a user control - BeeControl -was different to the one with the picture. The BeeControl was used to draw animated bees on the Hive and Field forms, if I am remembering correctly. For the exercises on p601 and 2, I created a WindowsApplication project and copied the files and resources from the project that drew the Bee, Flower, and "Nectar here" string. That project did not include a user control, or at least, mine didn't!

Note from the Author or Editor:
In the first line under step 3, change DrawBees() to DrawBee(), and put it in Courier code font.

Anonymous  Jul 08, 2008  Sep 01, 2008
Printed
Page 602
Step 2 code example

Step 1 says to double-click on Paint in the Form's Events list. This produces an Event Handler called Form1_Paint. Step 2 shows this code but now it's called UserControl1_Paint. Surely it should (still) be Form1_Paint? In the first line of code under step 2, change “UserControl1_Paint” to “Form1_Paint”.

Anonymous    Sep 01, 2008
Printed
Page 602
Step 3 first sentence

Step 3 says:- "Add the new DrawBees() method from the previous page into your new user control." Firstly, the method from the previous page is called DrawBee () not DrawBees. Secondly, the last project that included a user control - BeeControl -was different to the one with the picture. The BeeControl was used to draw animated bees on the Hive and Field forms, if I am remembering correctly. For the exercises on p601 and 2, I created a WindowsApplication project and copied the files and resources from the project that drew the Bee, Flower, and "Nectar here" string. That project did not include a user control, or at least, mine didn't! In the first line under step 3, change “DrawBees()” to “DrawBee()”, and put it in Courier code font.

Anonymous    Sep 01, 2008
Printed
Page 606
first answer, last line

change "programmatically" to "in code"

Anonymous    Jan 01, 2008
Printed
Page 606
fourth answer, fifth line from the bottom

change "got CreateGraphics() method" to "got a CreateGraphics() method"

Anonymous    Jan 01, 2008
Printed
Page 606
- fifth answer, first paragraph, second sentence

change "When a class implements IDisposable, any time you instantiate it you should call its dispose() method." to "When you instantiate a class that implements IDisposable, you should always call its Dispose() method when you're done with the object. That way it knows to clean up after itself."

Anonymous    Jan 01, 2008
Printed
Page 606
last answer

Remove the last sentence ("You'll see more about that in just a minute.")

Anonymous    Jan 01, 2008
Printed
Page 607
second paragraph

change "most amateur computer games..." to "some amateur computer games, for example."

Anonymous    Jan 01, 2008
Printed
Page 615
step 5, last line of code

Add an annotation pointing to "DrawBee" that says: "We'll reuse our DrawBee() method from a few pages ago."

Anonymous    Jan 01, 2008
Printed
Page 625
fifth annotation that starts "You can leave out"

Replace this annotation with: "Don't worry about drawing the Clone and List objects -- just add the objects for the Captain, the Swindler, the clone factory and Swindler's escape plane."

Anonymous    Jan 01, 2008
Printed
Page 629
code in the bottom right-hand of the page

indent the "clones.Remove(clone);" line by three spaces

Anonymous    Jan 01, 2008
Printed
Page 629

Change the fifth paragraph from this: Finally, .NET sends the garbage collector out again. This time, your object is dead, and the collector tosses it away. Here, finally, your destructor runs... possibly several minutes after the last reference to the object was removed or changed. To this: Finally, .NET sends the garbage collector out again. Your destructor runs... possibly several minutes after the last reference to the object was removed or changed. Now that it’s been finalized, your object is dead, and the collector tosses it away.

Anonymous    Sep 01, 2008
Printed
Page 633
second annotation starting "This is straight"

change this annotation to: "The Clone will create the C:Temp directory and serialize itself out to a file called Clone.dat."

Anonymous    Jan 01, 2008
Printed
Page 633
third annotation starting "You could set a class"

change this annotation to: "We hardcoded the filename -- we included them as string literals in the code. That's fine for a small demo program like this, but it's not the most robust design. Can you think of problems this might cause, and how you could avoid them?"

Anonymous    Jan 01, 2008
Printed
Page 635

In the first question, fourth line, change this: “may have already been collected.” To this: “may have already been finalized.”

Anonymous    Sep 01, 2008
Printed
Page 637

Add an annotation pointing to the second paragraph of body text in the middle of the page: “All structs inherit from System.ValueType, which in turn inherits from System.Object. That’s why every struct has a ToString() method – it gets it from Object. But that’s all the inheriting that structs are allowed to do.”

Anonymous    Sep 01, 2008
Printed
Page 637

In the sidebar, change this: “Structs are best used for storing data, but are not as useful as objects when it comes to representing actual behavior.” To this “Structs are best used for storing data, but the lack of inheritance and the way they’re managed in memory can be a serious limitation.” Add an annotation pointing to this sentence: “That’s why you don’t usually find yourself defining your own structs. But that doesn’t mean they don’t have their uses!”

Anonymous    Sep 01, 2008
Printed
Page 638
first block of code, first line

change 37 to 25

Anonymous    Jan 01, 2008
Printed
Page 638

In the second line of body text, change “string” to “decimal”. Change the second line of code under the first bullet from this: string name = “Fingers”; to this: bool Scary = true; And in annotation pointing to that line of code, change this: “int and bool” To this: “int and bool”

Anonymous    Sep 01, 2008
Printed
Page 639

Next to step 1, add this annotation (no arrow): Remember back in the beginning of the book when we said that methods and statements ALWAYS live in classes? Well, it turns out that's not quite exactly 100% accurate -- they can also live in structs.

Anonymous    Sep 01, 2008
Printed
Page 642

Add an annotation on page 642 pointing to step #2: “There’s a special case where value types don’t get boxed: if they live inside an object. If you’ve got a class with an int field, that int doesn’t need to be boxed before it’s added to the heap, because it’s already got a container – the object that it’s a part of.”

Anonymous    Sep 01, 2008
Printed
Page 643
Halfway through code on left

Line 5 of the code on the left should be wine.Set(book); Alternatively, the Set method in the Table struct could be called SetA. Similarly, line 6 of the code on the left should be book.Set(wine); Or, the Set method in the Hinge class should be called SetB.

Note from the Author or Editor:
In lines 5 and 6 of the code on the left-hand side of the page, change SetA and SetB to Set: wine.Set(book); book.Set(wine);

Anonymous  Jul 23, 2008  Sep 01, 2008
Printed
Page 643
Halfway through code on left

Line 5 of the code on the left should be wine.Set(book); Alternatively, the Set method in the Table struct could be called SetA. Similarly, line 6 of the code on the left should be book.Set(wine); Or, the Set method in the Hinge class should be called SetB. In lines 5 and 6 of the code on the left-hand side of the page, change “SetA” and “SetB” to “Set”: wine.Set(book); book.Set(wine);

Anonymous    Sep 01, 2008
Printed
Page 644
third answer, second sentence

change "familiar field from" to "familiar code from"

Anonymous    Jan 01, 2008
Printed
Page 646
top paragraph, first line

Add an annotation pointing to the word "sealed" in the first line that says: "Remember the sealed access modifier from Chapter 7? It's how you set up a class that can't be extended."

Anonymous    Jan 01, 2008
Printed
Page 647
second answer, first two sentences ("Sure. But then you'd need ... would have to change.")

Change these sentences to: "If you can extend the class, then you'll usually end up doing that -- extension methods aren't meant to be a replacement for inheritance. But they come in really handy when you've got classes that you can't extend."

Anonymous    Jan 01, 2008
Printed
Page 648
first paragraph

Add this to the end of the first paragraph: "Create a new project, and add a file called MyExtensions.cs."

Anonymous    Jan 01, 2008
Printed
Page 648
step 1, first line of code

change "Emergency" to "MyExtensions"

Anonymous    Jan 01, 2008
Printed
Page 648
step 3, first line of code

change "HumanExtensions" to "StringExtensionMethods"

Anonymous    Jan 01, 2008
Printed
Page 648
step 4, first sentence

change "Add using Emergency; to your code." to "Now go to your form code and add using MyExtensions; to the top, and add a button to the form so you can try out your new extension method inside its event handler."

Anonymous    Jan 01, 2008
Printed
Page 648
top paragraph, step 1 code, step 3 code

The name of the class is inconsistent throughout the example. The end of the first paragraph tells the reader to add a file called MyExtensions.cs The name of the class in step 1 is HumanExtensions The name of the class in step 3 is StringExtensions Pick one of the three and stick to it!

Note from the Author or Editor:
In the last line of bodytext, change MyExtensions.cs to HumanExtensions.cs, and put it in Courier code font. In the first line of code under step 3, change StringExtensionMethods to HumanExtensions

Anonymous  Jul 23, 2008  Sep 01, 2008
Printed
Page 648
top paragraph, step 1 code, step 3 code

The name of the class is inconsistent throughout the example. The end of the first paragraph tells the reader to add a file called MyExtensions.cs The name of the class in step 1 is HumanExtensions The name of the class in step 3 is StringExtensions In the last line of bodytext, change “MyExtensions.cs” to “HumanExtensions.cs”, and put it in Courier code font. In the first line of code under step 3, change “StringExtensionMethods” to “HumanExtensions

Anonymous    Sep 01, 2008
Printed
Page 649

change this magnet: public static void Main { To this: public static void Main() { Add semicolons to the ends of these two magnets: string s = i.ToPrice() s.SendIt() Change these two magnets that say “b.Green();” To this: b.Green().SendIt();

Anonymous    Sep 01, 2008
Printed
Page 650
Column of magnets on the right

The code for the Extension Magnets won't run as written. The Main method is missing parentheses. It should be Main() The 5th and 6th lines are missing semicolons. (The are also missing semicolons on the magnets on page 649) They should be: string s = i.ToPrice(); s.SendIt(); In order to get the correct output, both the 8th and 10th lines are missing part of the code. They should both be: b.Green().ToPrice(); Also, there should be two more magnets on page 649 that say, ".SendIt();"

Note from the Author or Editor:
Add semicolons to the ends of these two magnets: string s = i.ToPrice() s.SendIt() Change these two magnets that say b.Green(); To this: b.Green().SendIt() There are five magnets that need to be changed on pages 649 and 650 (all five magnets appear on both pages)

Anonymous  Jul 23, 2008  Sep 01, 2008
Printed
Page 650
Column of magnets on the right

The code for the Extension Magnets won't run as written. The Main method is missing parentheses. It should be Main() The 5th and 6th lines are missing semicolons. (The are also missing semicolons on the magnets on page 649) They should be: string s = i.ToPrice(); s.SendIt(); In order to get the correct output, both the 8th and 10th lines are missing part of the code. They should both be: b.Green().ToPrice(); Also, there should be two more magnets on page 649 that say, ".SendIt();" There are five magnets that need to be changed on pages 649 and 650 (all five magnets appear on both pages).

Anonymous    Sep 01, 2008
Printed
Page 650

change this magnet: public static void Main { To this: public static void Main() { Add semicolons to the ends of these two magnets: string s = i.ToPrice() s.SendIt() Change these two magnets that say “b.Green();” To this: b.Green().SendIt();

Anonymous    Sep 01, 2008
Printed
Page 655
bottom left-hand annotation

Change "All of the Objectville" to "All of the Objectville Paper Company"

Anonymous    Jan 01, 2008
Printed
Page 655
Brain Power box

change "Objectville paper" to "Objectville Paper Company data"

Anonymous    Jan 01, 2008
Printed
Page 656
add an annotation pointing to the first paragraph

We gave you Ready Backe Code for the LINQ query in Chapter 12. We'll see exactly how it works in a few pages.

Anonymous    Jan 01, 2008
Printed
Page 658
"var" tool tip box

Put the two lines of code in boldface

Anonymous    Jan 01, 2008
Printed
Page 659
Brain Power

change "Jim" to "Jimmy"

Anonymous    Jan 01, 2008
Printed
Page 660
first sentence

Change "It's easy to mine Jimmy's data" to "Jimmy could analyze his comic book data"

Anonymous    Jan 01, 2008
Printed
Page 669,670
Pool Puzzle Solution, initialization of lines array

Page 669 uses this code to initialize the lines array:- Line [] lines = { new Line ( { "eating", "carrots,", "but", "enjoy", "Horses" } , 1), etc. while the Pool Puzzle Solution on p670 has:- Line [] lines = { new Line ( new { "eating", "carrots,", "but", "enjoy", "Horses" } , 1), ... which at least recognises that the Words (string) array is new. However, both of these cause errors in the IDE. The correct code should read:- Line [] lines = { new Line ( new string [] { "eating", "carrots,", "but", "enjoy", "Horses" } , 1) new Line ( new string [] { "zebras", "Cows", "hay", "bridge", "bolted" } , 2), new Line ( new string [] { "fork", "dogs!", "engine", "and" } , 3), new Line ( new string [] { "love", "they", "apples.", "eating" } , 2 ), new Line ( new string [] { "whistled.", "Bump" } , 1 ) }; Here each Line's Words arrays is declared as a new string [].

Note from the Author or Editor:
In the left-hand block of code, there are five lines that start with: new Line( { ... Change them so they start with: new Line( new string[] { ...

Anonymous  Jun 16, 2008  Sep 01, 2008
Printed
Page 669

Page 669 uses this code to initialize the lines array:- Line [] lines = { new Line ( { "eating", "carrots,", "but", "enjoy", "Horses" } , 1), etc. while the Pool Puzzle Solution on p670 has:- Line [] lines = { new Line ( new { "eating", "carrots,", "but", "enjoy", "Horses" } , 1), ... The correct code should read:- Line [] lines = { new Line ( new string [] { "eating", "carrots,", "but", "enjoy", "Horses" } , 1) new Line ( new string [] { "zebras", "Cows", "hay", "bridge", "bolted" } , 2), new Line ( new string [] { "fork", "dogs!", "engine", "and" } , 3), new Line ( new string [] { "love", "they", "apples.", "eating" } , 2 ), new Line ( new string [] { "whistled.", "Bump" } , 1 ) }; In the left-hand block of code, there are five lines that start with: new Line( { “... Change them so they start with: new Line( new string[] { “...

Anonymous    Sep 01, 2008
Printed
Page 670
Pool Puzzle Solution, first annotation

Whoops, sorry, sent that before I'd overtyped the new description! The annotation states: This first LINQ query divides the Line objects in the line[] array into two groups, grouped by their Value, ... Surely there are three groups, with Value = 1, 2 and 3? We actually want only the first two, but that hasn't happened yet.

Note from the Author or Editor:
In the second line of the top annotation, change 'into two groups' to 'into groups'

Anonymous  Jun 16, 2008  Sep 01, 2008
Printed
Page 670
Pool Puzzle Solution

Page 669 uses this code to initialize the lines array:- Line [] lines = { new Line ( { "eating", "carrots,", "but", "enjoy", "Horses" } , 1), etc. while the Pool Puzzle Solution on p670 has:- Line [] lines = { new Line ( new { "eating", "carrots,", "but", "enjoy", "Horses" } , 1), ... which at least recognises that the Words (string) array is new. However, both of these cause errors in the IDE. The correct code should read:- Line [] lines = { new Line ( new string [] { "eating", "carrots,", "but", "enjoy", "Horses" } , 1) new Line ( new string [] { "zebras", "Cows", "hay", "bridge", "bolted" } , 2), new Line ( new string [] { "fork", "dogs!", "engine", "and" } , 3), new Line ( new string [] { "love", "they", "apples.", "eating" } , 2 ), new Line ( new string [] { "whistled.", "Bump" } , 1 ) }; Here each Line's Words arrays is declared as a new string [].

Note from the Author or Editor:
In the left-hand block of code, there are five lines that start with: new Line( { ... Change them so they start with: new Line( new string[] { ...

Anonymous  Jun 16, 2008  Sep 01, 2008
Printed
Page 670
Pool Puzzle, initialization of lines array

In the left-hand block of code, there are five lines that start with: new Line( { “... Change them so they start with: new Line( new string[] { “...

Anonymous    Sep 01, 2008
Printed
Page 670
Pool Puzzle Solution, first annotation

Whoops, sorry, sent that before I'd overtyped the new description! The annotation states: This first LINQ query divides the Line objects in the line[] array into two groups, grouped by their Value, ... Surely there are three groups, with Value = 1, 2 and 3? We actually want only the first two, but that hasn't happened yet. In the second line of the top annotation, change “into two groups” to “into groups”

Anonymous    Sep 01, 2008
Printed
Page 671
first paragraph, third line

change "class with two fields" to "class with two automatic properties"

Anonymous    Jan 01, 2008
Printed
Page 671
Annotation to Step 3, second sentence

The annotation, second sentence states: "When you use an object initializer, you create an anonymous by typing a series of names and values inside curly brackets." It should say something like "... you create an anonymous object..." or "an anonymous type object", though the latter is not so good.

Note from the Author or Editor:
In third line of the bottom left-hand annotation, change 'you create an anonymous' to 'you create an anonymous object'

Anonymous  Jun 17, 2008  Sep 01, 2008
Printed
Page 671
Annotation to Step 3, second sentence

The annotation, second sentence states: "When you use an object initializer, you create an anonymous by typing a series of names and values inside curly brackets." It should say something like "... you create an anonymous object..." or "an anonymous type object", though the latter is not so good. In third line of the bottom left-hand annotation, change “you create an anonymous” to “you create an anonymous object”

Anonymous    Sep 01, 2008
Printed
Page 672
Sample code for Step 1

The definition for method FindPurchases starts:- public sList<Purchase> FindPurchases() ... My IDE doesn't seem to know what an sList is, and neither do I, so I'm guessing it should read:- public List<Purchase> FindPurchases() ...

Note from the Author or Editor:
In the first line of code, change public sList to public List

Anonymous  Jun 20, 2006  Sep 01, 2008
Printed
Page 672
Sample code for Step 1

The definition for method FindPurchases starts:- public sList<Purchase> FindPurchases() ... My IDE doesn't seem to know what an sList is, and neither do I, so I'm guessing it should read:- public List<Purchase> FindPurchases() ... In the first line of code, change “public sList” to “public List”

Anonymous    Sep 01, 2008
Printed
Page 677
there are no Dumb Questions, Answer 4

The answer starts:- "Yes, you do have to create them. LINQ object that implements the IEnumerable interface." This doesn't make sense. The first sentence could say just:- "Yes, you do." "have to add them" would match the terminology of the question. That second sentence could state:- "LINQ can only be used with objects that implement the IEnumerable interface." or, slightly shorter but perhaps not so clear:- "LINQ objects must implement the IEnumerable interface." though that runs better into the following explanation. Also, para 2 sentence 2 says:- "When you add it to your project, it automatically does everything..." The first "it" should the "them" to match the LINQ to SQL classes (plural), while the second "it" refers to the IDE, so it would be clearer if it said "the IDE"! The following "it"s would then refer to the IDE again.

Note from the Author or Editor:
Change the first two sentences of the fourth answer to: A: Yes, you do. LINQ needs an object that implements the IEnumerable interface. In the second paragraph of the fourth answer, change 'it' to 'they' and match the number throughout: That's why the IDE provides the LINQ to SQL classes for you. When you add them to your project, they automatically do everything you need in order to connect LINQ to a SQL database: they let you drag database objects into its Object Relational Designer, and when you do they automatically read your database’s tables and create classes (like the People class) that LINQ can use to access them.

Anonymous  Jun 20, 2008  Sep 01, 2008
Printed
Page 677
there are no Dumb Questions, Answer 4

The answer starts:- "Yes, you do have to create them. LINQ object that implements the IEnumerable interface." This doesn't make sense. The first sentence could say just:- "Yes, you do." "have to add them" would match the terminology of the question. That second sentence could state:- "LINQ can only be used with objects that implement the IEnumerable interface." or, slightly shorter but perhaps not so clear:- "LINQ objects must implement the IEnumerable interface." though that runs better into the following explanation. Also, para 2 sentence 2 says:- "When you add it to your project, it automatically does everything..." The first "it" should the "them" to match the LINQ to SQL classes (plural), while the second "it" refers to the IDE, so it would be clearer if it said "the IDE"! The following "it"s would then refer to the IDE again. Change the first two sentences of the fourth answer to: A: Yes, you do. LINQ needs an object that implements the IEnumerable interface. In the second paragraph of the fourth answer, change “it” to “they” and match the number throughout: That’s why the IDE provides the LINQ to SQL classes for you. When you add them to your project, they automatically do everything you need in order to connect LINQ to a SQL database: they let you drag database objects into its Object Relational Designer, and when you do they automatically read your database’s tables and create classes (like the People class) that LINQ can use to access them.

Anonymous    Sep 01, 2008
Printed
Page 679
Step 3, code example, join line

There is an inconsistency in the code. The data context variable for the Contacts database is originally created as "context" but the join line that links it to the Starbuzz data calls it "dataContext". This will not compile. It would be better to use "context" for both of them but dataContext would also be OK, but perhaps a bit too long.

Note from the Author or Editor:
In the sixth line of code, change dataContext to context

Anonymous  Jun 25, 2008  Sep 01, 2008
Printed
Page 679
Step 3, code example, join line

There is an inconsistency in the code. The data context variable for the Contacts database is originally created as "context" but the join line that links it to the Starbuzz data calls it "dataContext". This will not compile. It would be better to use "context" for both of them but dataContext would also be OK, but perhaps a bit too long. In the sixth line of code, change “dataContext” to “context”

Anonymous    Sep 01, 2008
Printed
Page 683
left-hand annotation starting with "The spacebar shoots"

Change "there can only be two shots" to "there can only be two player shots"

Anonymous    Jan 01, 2008
Printed
Page 683
right-hand annotation that starts "The game should keep"

change "all keypresses" to "which keys are currently being held down"

Anonymous    Jan 01, 2008
Printed
Page 685
bottom annotation

Change "The Stars keeps" to "The Stars object keeps"

Anonymous    Jan 01, 2008
Printed
Page 686
second annotation

change "DisplayRectangle" to "ClientRectangle"

Anonymous    Jan 01, 2008
Printed
Page 687
bottom subheading

change "Adjust the timer" to "Adjust the timers"

Anonymous    Jan 01, 2008
Printed
Page 689
second to last paragraph, last line

change "Refresh()" to "Invalidate()"

Anonymous    Jan 01, 2008
Printed
Page 689
last paragraph

Add this sentence to the end of the paragraph: "You can start the game out in this state, so the user has to hit S to start a new game."

Anonymous    Jan 01, 2008
Printed
Page 691
second paragraph

replace the whole paragraph with this text: So the form should have a Paint event handler (make sure you set the form's DoubleBuffered property to true!). You'll delegate the rest of the drawing to the Game object by calling its Draw() method every time the form's Paint event fires.

Anonymous    Jan 01, 2008
Printed
Page 694
second paragraph

Change DisplayRectangle to ClientRectangle

Anonymous    Jan 01, 2008
Printed
Page 704
1st paragraph, 3rd line

"Add add" s/b "Add"

Anonymous    Jan 01, 2008
Printed
Page 707
add an annotation pointing to the last paragraph

Plus, it'll even figure out that it should create a static method, since it doesn't use any fields.

Anonymous    Jan 01, 2008
Printed
Page 710
Annotation in bottom-right corner of page, 4th line

"applicaiton" s/b "application"

Anonymous    Jan 01, 2008
Printed
Page 712
3rd paragraph, 1st line

Missing period. "application Just" s/b "application. Just"

Anonymous    Jan 01, 2008
Printed
Page 712

In the header and first line of body text change “Windows Presentation Framework” to “Windows Presentation Foundation”.

Anonymous    Sep 01, 2008
Printed
Page 718

Index "argument"

Anonymous    Sep 01, 2008