Microsoft® Visual C#® 2010 Step by Step

Errata for Microsoft® Visual C#® 2010 Step by Step




The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed, PDF
Page 13
Step 4 - first sentence

Text states the following: "this is the leftmost button on the toolbar" when the referenced image clearly shows it is second from the left.

Note from the Author or Editor:
The reader is correct. The text in step 4 should state that this is the second leftmost button on the toolbar.

Jason Perry  Sep 13, 2011  Jan 20, 2012
Printed
Page 24
2nd paragraph, 2nd line

"Application.xaml.cs" should be "App.xaml.cs"

Note from the Author or Editor:
The reader is correct. On page 24, in the paragraph above the 2nd code example, the reference to the file Application.xaml.cs should be App.xaml.cs.

Anonymous  Jan 16, 2011  Jul 29, 2011
Printed
Page 31
in data type table

it says float's range is +-1.5 X 10^45 through ... There should be a negative in the exponent ==> 10^45 should be 10^-45

Note from the Author or Editor:
In the third column of the third row of the table at the bottom of page 31, the exponent in the starting point of the range should be 10^-45

Joe Baden  Jul 11, 2011  Jul 29, 2011
Printed
Page 37
para 3, Line 6:

Error: "C# always rounds down in circumstances like this."; Correction: "C# always rounds towards zero in circumstances like this. Hence, 57 / 10 = 5, and -57 / 10 = -5.

Note from the Author or Editor:
The reader is correct. In the penultimate paragraph on page 37, the sentence starting on the 6th line should read: "C# always rounds towards zero in circumstances like this"

Anonymous  Mar 07, 2011  Jul 29, 2011
Printed
Page 41
3rd line

"...must convert the string to an int..." is wrong way round. Should read "...convert the int to a string...". -- jj

Note from the Author or Editor:
The reader is correct. The 2nd sentence at the top of page 41 should read: "Remember that the Text property is a string and that the result of the calculation is an int, so you must convert the int to a string before assigning it to the Text property."

Mr J Jameson  Sep 13, 2010  Nov 01, 2010
PDF
Page 61
section 4. (where it shows a picture of the Debug toolbar)

On the image showing the Debug toolbar, the Step Out and Step Over are mislabeled.

Note from the Author or Editor:
The reader is correct. The labels for the Step Over and Step Into buttons should be reversed.

Anonymous  Feb 22, 2011  Jan 20, 2012
Printed
Page 67
1/3 down

optMethod(1, 2.5. "World"); should be; optMethod(1, 2.5, "World"); Comma replaces period.

Note from the Author or Editor:
This is a typo rather than a technical error. In the second block of code on the page, the statement should read: optMethod(1, 2.5, "World"); with a comma instead of the dot after "2.5"

Darren Paul Harker  Apr 14, 2011  Jul 29, 2011
Safari Books Online
71
5th line

Because theDailyRate variable is bound to the double struct we should probably amend the semantic for calculateFee method: - is double fee = calculateFee(theDailyRate : 375); - should be double fee = calculateFee(theDailyRate : 375.0);

Note from the Author or Editor:
This is only a minor point as the compiler will automatically convert an int to a double, but it would be good practice to be consistent with the rest of the chapter. On page 71, in the code for step 17, change: double fee = calculateFee(theDailyRate : 375); to double fee = calculateFee(theDailyRate : 375.0);

Marcin Aumiler  Oct 12, 2010  Nov 01, 2010
Printed
Page 81
UK

In item 7 at the top of page 81, in the first line of code, there is a mismatch with what's provided on the CD. The book reads private int compareClick(object sender, RoutedEventArgs e) The CD reads private void compareClick(object sender, RoutedEventArgs e)

Note from the Author or Editor:
The code on the CD is correct. The code in the book should be changed to read: private void compareClick(object sender, RoutedEventArgs e)

John Gray  Nov 26, 2010  Jul 29, 2011
Printed
Page 88
point 8;

"case '<' : target.Text += "<"; break; If the current character being copied is a >, this code appends the string "<" to the text being output in its place." -- The character should be < to reflect the example code.

Note from the Author or Editor:
The sentence below the code in step 8 should be: "If the current character being copied is a <, this code appends the string "&lt;" to the text being output in its place."

Anonymous  Jun 30, 2010  Nov 01, 2010
Printed
Page 94
last paragraph

Paragraph reads "The third statement *assigns the Text property of the filename control to the Name property of the src variable*." should this be: "The third statement assigns the Name property of the src variable to the Text property of the filename control."?

Note from the Author or Editor:
The reader is correct. The first sentence in the final paragraph at the bottom of page 94 should read: The third statement assigns the Name property of the src variable to the Text property of the filename control.

Anonymous  Jan 27, 2011  Jul 29, 2011
Printed
Page 116
Lower bottom of page, # 9

The book reads "9. Display the code for the file Window1.xaml.cs in the Code and Text Editor window, and locate the calculateClick mehotd." I think "Window1.xaml.cs" should be "MainWindow.xaml.cs" simply because this is the only file I am seeing.

Note from the Author or Editor:
The reader is correct. In step 9, Window1.xaml.cs should be MainWindow.xaml.cs.

Sean  Aug 28, 2010  Nov 01, 2010
Safari Books Online
120 122 123 124
5th paragraph

5. In the Code and Text Editor window displaying Window1.xaml.cs, locate the multiplyValues method. It looks like this: The previous speaker found this typo, it appeared again: Window1.xaml.cs should be replaced with MainWindow.xaml.cs

Note from the Author or Editor:
The reader is correct. In step 5 on page 120, Window1.xaml.cs should be MainWindow.xaml.cs. The same issue occurs in step 9 on page 116 (already reported, but repeated here for completeness), as well as step 5 on page 122, step 1 on page 123, and step 1 on page 124.

Marcin Aumiler  Oct 13, 2010  Nov 01, 2010
Printed
Page 147
2nd last paragraph

The sentence reads "This class contains two public fields called Name (initialized to the string "John") and Age (initialized to the integer 42). I believe the 42 should read 44, simply because of the line above the paragraph which reads: myAnonymousObject = new {Name = "John", Age = 44 };

Note from the Author or Editor:
The reader is correct. The sentence should read: This class contains two public fields called Name (initialized to the string "John") and Age (initialized to the integer 44).

Sean  Aug 30, 2010  Nov 01, 2010
Printed
Page 172
1st code block

Would the 'out' keyword quick reference be better explained without int arg being assigned within main?

Note from the Author or Editor:
The reader is correct. The statement: int arg = 42; in the first code block might be better as: int arg;

Darren Paul Harker  Apr 18, 2011  Jul 29, 2011
Printed
Page 183
graphics on the page

The two graphics on the page are reversed. They do no match the text preceding each graphic.

Note from the Author or Editor:
The two images on page 183 should be swapped over

Anonymous  Jun 13, 2010  Nov 01, 2010
Printed
Page 195
two thirds down

Minor mistake. Current: "the compiler throws an IndexOutOfRangeException" Correction: "the runtime throws an IndexOutOfRangeException" The range of a dynamically-sized array is not known at compile time.

Note from the Author or Editor:
The reader is correct. The sentence immediately before the code near the bottom of the page should read: If you specify an index that is less than 0 or greater than or equal to the length of the array, the runtime throws an IndexOutOfRangeException, as shown in this example:

Adam C  Feb 26, 2012  Oct 12, 2012
Printed
Page 201
Step 11 - Add the following code shown in bold...

None of the code shown is in bold, it should all be! I have come across a couple of other examples where the code to be entered was not in bold.[but didn't note the reference]. I'm rather new to this, so it may well be obvious from the text explanation; at the moment I just follow the instructions and if it's not bold it doesn't get entered - until I find that what I have entered doesn't work!

Note from the Author or Editor:
The reader is correct. All of the code for step 11 on page 210 should be bold

David Barrett  Mar 22, 2011  Jul 29, 2011
Printed
Page 209
top half of page

2 commented lines about the number of iterations for for loop and foreach loop should state "//iterate remaining 11 elements..." instead of 10 elements

Note from the Author or Editor:
The reader is correct. On page 209, the comment: // Iterate remaing 10 elements using a for statement Should be: // Iterate remaing 11 elements using a for statement Similarly, the statement: // Iterate remaing 10 elements using a foreach statement Should be: // Iterate remaing 11 elements using a foreach statement

Anonymous  Jan 29, 2011  Jul 29, 2011
Printed
Page 222
Final bullet at the bottom of the page

The final bullet and code example at the bottom of the page contradicts the previous bullets and is wrong. It should be removed. The text to be removed is: The compiler detects and rejects any potentially ambiguous overloads. For example, the following two Min methods are ambiguous; it’s not clear which one should be called if you pass two int arguments: // compile-time error public static int Min(params int[] paramList) ... public static int Min(int, params int[] paramList) ...

John Sharp
John Sharp
O'Reilly Author 
Jan 09, 2012  Jan 20, 2012
Printed
Page 241
Near the lower middle of the page(last line of code snippet)

The comment which shows the intended output of the line of code is // Aardvark, but in the description in the two last lines of the second last paragraph it states that the output is: // Mammal

Note from the Author or Editor:
The comment at the end of the line of code should be: // Mammal

Kristjan Stefansson  Sep 27, 2013 
Printed
Page 269
Code sample in lower part of the page

The two implementations of the ChewGrass methods in the Horse class should not have a sem-colon after the closing curly brace. The correct code should look like this: class Horse : Mammal, ILandBound, IGrazable { ... void IGrazable.ChewGrass() { Console.WriteLine(“"Chewing grass”"); // code for chewing grass } } class Sheep : Mammal, ILandBound, IGrazable { ... void IGrazable.ChewGrass() { Console.WriteLine(“"Chewing grass”"); // same code as horse for chewing grass } }

John Sharp
John Sharp
O'Reilly Author 
Jan 09, 2012  Jan 20, 2012
PDF
Page 276
2nd footnote

The footnote reads: A structure implicitly derives from System.Object, which contains methods that the structure can hide. but the entry in the table indicates that the structure can *not* hide any methods. The footnote should read: 'A structure implicitly derives from System.Object, which contains no methods that the structure can hide.'

Note from the Author or Editor:
Actually, the converse is true. The entries in the final column (Structure) for the rows labelled "new" and "override" are now out of date. They should both be "yes" rather than "no", and footnotes 2 and 3 should be deleted.

Anonymous  Aug 08, 2010  Nov 01, 2010
Printed
Page 277
section name: *Chapter 13 Quick Reference*

page 277 section name: *Chapter 13 Quick Reference* error: > class Test : IDemo > { > public string IDemo.Name() > { > ... > } > public string IDemo.Description() > { > ... > } > } compile time error: The modifier 'public' is not valid for this item

Note from the Author or Editor:
The reader is correct. You cannot use a modifier such as public or private when you implement an interface explicitly.

Anonymous  Oct 25, 2012 
Printed
Page 302
Properties and Field Names: A Warning box at top of page

public int EmployeeID should not have a semicolon after the header line of the property.

Note from the Author or Editor:
The reader is correct. The code in the Warning box at the top of page 302 should read: class Employee { private int employeeID; public int EmployeeID { get { return this.EmployeeID; } set { this.EmployeeID = value; } } }

darlene westberg  Feb 22, 2012  Oct 12, 2012
Printed
Page 316
4th bullet point (The AND (&) operator)

Part of this bullet point states states: "So 204 & 20 is 8 (204 is 11001100, 24 is 00011000, and 8 is 00001000)." The first statement is incorrect; it should read "So 204 & 24 is 8".

Note from the Author or Editor:
The reader is correct. The final sentence of bullet point 4 (The AND operator) should state: So 204 & 24 is 8 (204 is 11001100, 24 is 00011000, and 8 is 00001000).

Matt Dale  Apr 10, 2011  Jul 29, 2011
Printed
Page 316
Towards the bottom of page

The example says (1 << 6) returns 00100000. This is incorrect, the correct value is 01000000.

Note from the Author or Editor:
The reader is correct. In the examples at the bottom of page 316, every occurence of the following expression: 1 << 6 Should be replaced with: 1 << 5 This occurs 3 times

Anonymous  Sep 28, 2010  Nov 01, 2010
Printed
Page 317, 319
third line of code, on top of page

it should be 5 instead of 6 as shown below: bool peek = bits[5]; //retrive bool at index 5; should be true (1)

Note from the Author or Editor:
Agreed. However, the remaining example code fragments on page 319 also refer to bits[6]. I suggest that we change the following line of code: int adapted = 62; // 62 has the binary representation 111110 To: int adapted = 126; // 126 has the binary representation 1111110 The final comment in the code block must also be changed to: // the value in adapted is now 1110111, or 119 in decimal --------- Additionally, on page 317, the first Note needs to change. The final phrase should be ", and the bit at position 6 is the bit seven places from the right."

Cesar Lima  Aug 09, 2010  Jul 29, 2011
Printed
Page 319
1st code block

Comment in code block is wrong about "the value of adapted is now ..." because the value of adapted is unchanged. Only the value of "bits" changed.

Note from the Author or Editor:
The values specified in the comment are also wrong! The final comment in the block of code near the top of the page should be: // the value in bits is now 110111, or 55 in decimal

Harry Parker  Jul 03, 2011  Jan 20, 2012
Printed
Page 319
6th line of code

From Derrick Harrison, Calgary, Canada. [derrick.harrsison@shaw.ca] Page 319 Obviously this page has generated some interest because when I first checked the errata there was a entry dated Jan 20, 2012 which was totally incorrect. I agree that the entry dated July 29 2011 is correct as far as the bits are concerned. However I do not think the statement “the value of adapted is now 119” is correct. When I tested this code the value of adapted was unchanged at 126. I assume this is because adapted is passed as a reference to the structure and it is the private int bits field that is changed. When I added a method: public int getBits() { return bits; } to the structure and then added adapted = bits.getBits(}; after bits[3] = false; then adapted was indeed changed to 119. I have a few other comments which are minor in nature. Page 185. In the Note – line 6; Date is a struct and not a class. Page 236. In the code Mammal1 MyMammal there should be a space between new and Mammal Page 266.Step 3. I think I would have called it an Events tab rather than an Events button. Page 546.Step 4. I don’t think the phrase “The SQL SELCT statement appears” is true, at least not on C# 2010 express. General comment. I went to my first computer lecture in England in 1959 and joined the computer industry in 1962. So I have seen a few changes in my time and programmed in almost all well know languages and some not so well known such as Mercury Autocoder.. Since retiring almost 20 years ago I have used Visual Basic almost exclusively but I thought I should get up to speed with C# because I think that is what I think I should be teaching the grandchildren. Also it is important to keep the brain alive as one ages. Of all the many computer books I have bought over the years I think this is definitely one of the best. I have actually only got up to Chapter 16 so far but I jumped ahead to Chapter25 because I thought I would try the SQL examples. In all previous books I was never able to get the examples to work exactly as the author had written. So I congratulate John Sharp for having done his homework. I realize that the 2012 book is probably now in print but maybe the above comments still apply.

Note from the Author or Editor:
I believe that some of these issues have already been addressed in the reprint earlier this year, The comments about pages 236 and 546 are new and will be addressed: On page 236, the code near the middle of the page should be: Mammal myMammal = new Mammal("Mammalia"); On page 546, the sentence before the graphic should say: The orders for the customer appear, as shown in the following image:

Derrick Harrison  Sep 20, 2012  Oct 12, 2012
Printed
Page 341
2nd example from top

Examples of lambda expressions being shown, and second example in my book is (ref int x, int y) { x++; return x / y; } It's missing the => symbol indicating a lambda expression.

Note from the Author or Editor:
The reader is correct, the code for the second example near the top of page 341 should be: (ref int x, int y) => { x++; return x / y; }

Warrick Wilson  May 27, 2011  Jul 29, 2011
Printed
Page 342
2nd line

The word "braces" should be "parentheses".

Note from the Author or Editor:
In the sidebar at the top of page 342, the penultimate sentence at the end of the 1st paragraph directly above the code example should read: "Also, any parameters needed are specified in parentheses following the delegate keyword."

Harry Parker  Jul 04, 2011  Jul 29, 2011
Printed
Page 350
Top of page; first sentence in step 12

The italicized LocalClickTick event should read LocalClockTick event.

Note from the Author or Editor:
The reader is correct. The text for step 12 at the top of page 350 should read: In the stopClick method, unsubscribe the displayLocalTime method from the LocalClockTick event.

Steven Gregory  Dec 28, 2010  Jul 29, 2011
Printed
Page 351
Second summary: Declare an event

Example shows delegate void myEvent(); class MyClass { public event myDelegate MyEvent; } I think "myEvent()" should be "myDelegate()", and then event declaration is correct.

Note from the Author or Editor:
The reader is correct. The code in the "Declare an event" summary section should be: delegate void myDelegate(); class MyClass { public event myDelegate MyEvent; }

Warrick Wilson  May 27, 2011  Jul 29, 2011
Printed
Page 373
Step 6, final sentence.

The final sentence states "The tree is passed back as the return value". This is not the case as the function's return type is void.

Note from the Author or Editor:
The final sentence in step 6 at the top of page 373 should be cut.

Matt Dale  May 28, 2011  Jul 29, 2011
Printed
Page 377
Bottom of page

I believe the code at the bottom of the page was intended to be: object x = ...; object y = ...; ObjectComparer objectComparer = new ObjectComparer(); IComparer<object> objectComparator = objectComparer; int result = objectComparator.Compare(x, y);

Note from the Author or Editor:
You are correct. The variable "comparer" declared on line 3 of the code should actually be named "objectComparer". The full code should be: object x = ...; object y = ...; ObjectComparer objectComparer = new ObjectComparer(); IComparer<object> objectComparator = objectComparer; int result = objectComparator.Compare(x, y);

Cesar Lima  Aug 12, 2010  Jul 29, 2011
Printed
Page 377
Center of page

The code for the class ObjectComparer should be as follow: class ObjectComparer : IComparer<object> { int IComparer<object>.Compare(object x, object y) { ... (as printed in the text) } }

Note from the Author or Editor:
The reader is correct. The definition of the Compare method in the ObjectComparer class is missing an "I" at the start (also the "O" at the start of "Object" should be uppercase, for consistency). The full code should be: class ObjectComparer : IComparer<Object> { int IComparer<Object>.Compare(Object x, Object y) { int xHash = x.GetHashCode(); int yHash = y.GetHashCode(); if (xHash == yHash) return 0; if (xHash < yHash) return -1; return 1; } }

Cesar Lima  Aug 12, 2010  Jul 29, 2011
Printed
Page 399
Center of page

It is missing the "this" keyword in the code of the extension method Select .

Note from the Author or Editor:
The definition of the select method on page 399 should be: public static IEnumerable<TResult> Select<TSource, TResult>( this IEnumerable<TSource> source, Func<TSource, TResult> selector )

Cesar Lima  Aug 18, 2010  Jul 29, 2011
Printed
Page 399
last paragraph

Line 3 error: TSource is the type of the collection... correction: TSource is the type of the elements in the collection... Line 11: error: ... yields a collection of TResult... correction: ... yields a TResult... Regarding Line 11, the Select method yields a collection of TResults, but the selector parameter expects a method that takes a single TSource element and returns a single TResult element.

Note from the Author or Editor:
The point the reader raises about line 3 is, I feel, a matter of interpretation and how one reads the sentence; I am quite happy quite happy for line 3 to be left as-is. Concerning line 11, the penultimate sentence in the paragraph at the bottom of page 399 should probably read: The method referred to by the selector parameter takes a TSource (in this case customr) parameter, and yields a TResult (in this case string) object.

Adam C  May 09, 2011  Jul 29, 2011
Printed, PDF
Page 403
Last example at the end of the page

Misnamed variable name and typo in a string constant: int numberOfCountries = addresses.Select(addr => addr.Country).Distinct().Count(); Console.WriteLine("Number of companies: {0}", numberOfCompanies); --- should be: int numberOfCountries = addresses.Select(addr => addr.Country).Distinct().Count(); Console.WriteLine("Number of countries: {0}", numberOfCountries);

Note from the Author or Editor:
The reader is correct. The following code statement near the bottom of page 403: Console.WriteLine("Number of companies: {0}", numberOfCompanies); Should be: Console.WriteLine("Number of countries: {0}", numberOfCountries);

Tomi Halonen  Dec 02, 2010  Jul 29, 2011
Printed
Page 404
Code after first paragraph

I believe the author's intention was to use the identifier countriesAndCustomers instead of citiesAndCustomers for the implicitly typed local variable. Even though this mistake does not cause an error it does impact understanding.

Note from the Author or Editor:
Agreed. Although everything works as specified, it might be more intuitive to change the name "citiesAndCustomers" where it appears in the code samples and text on page 404 to "companiesAndCustomers". This name occurs several times on the page.

Cesar Lima  Aug 18, 2010  Jul 29, 2011
Printed
Page 407
1st paragraph in section "Querying Data in Tree<ITitem> Objects"

In the second sentence, the reference to the IEnumerable interface should be the generic IEnumerable<T> interface.

Note from the Author or Editor:
In the second sentence of the specified paragraph, change the text "the IEnumerable interface" to "the generic IEnumerable<T> interface"

John Sharp
John Sharp
O'Reilly Author 
Nov 10, 2010  Jul 29, 2011
Printed
Page 428
Table in center of page

The calculation for the division operation is missing a leading parenthesis for the imaginary portion: (((a * c + b * d) / (c * c + d * d)) + (b * c - a * d) / (c * c + d * d))i) should be (((a * c + b * d) / (c * c + d * d)) + ((b * c - a * d) / (c * c + d * d))i) To be convinced, display the following in a monospaced font in an editor wide enough to display each line without a break. (((a * c + b * d) / (c * c + d * d)) + ((b * c - a * d) / (c * c + d * d))i) (((-------------) (-------------)) ((-------------) (-------------)) ) ((---------------------------------) (---------------------------------) ) (--------------------------------------------------------------------------)

Note from the Author or Editor:
The reader is correct. In the table near the middel of page 428, the value in the Calculation column for the complex division operation should be: (((a * c + b * d) / (c * c + d * d)) + ((b * c - a * d) / (c * c + d * d))i)

Steven Gregory  Dec 28, 2010  Jul 29, 2011
Printed
Page 430
Bold code for overloaded * operator after first paragraph.

This error does not in any way present a stumbling block to the understanding of operator overloading. It could however confuse the reader's understanding of complex numbers. public static Complex operator *(Complex lhs, Complex rhs) { // ERROR // return new Complex(lhs.Real * rhs.Real + lhs.Imaginary * rhs.Real, lhs.Imaginary * rhs.Imaginary + lhs.Real * rhs.Imaginary); // CORRECTED return new Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + rhs.Real * lhs.Imaginary); } Also, in the table on page 428, the * operator is correct, however, the imaginary portion of the / operator is missing a leading parenthesis.

Note from the Author or Editor:
This is a typo rather than a serious mistake. The reader is not quite correct, and appears to have made a similar error. The formula shown for performing complex multiplication shown in page 428 is correct, but the formula got mis-transposed into C# code. On page 430, code for the "Complex operator *" method in step 9 (near the top of the page), should be: return new Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary);

Steven Gregory  Dec 28, 2010  Jul 29, 2011
Printed
Page 430
top of page

public static Complex operator *(Complex lhs, Complex rhs) { return new Complex(lhs.Real * rhs.Real + lhs.Imaginary * rhs.Real, lhs.Imaginary * rhs.Imaginary + lhs.Real * rhs.Imaginary); } is not returning the desired output. I think it should be: return new Complex(lhs.Real * rhs.Real + lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary);

Note from the Author or Editor:
The code for the operator* method in the first example at the top of page 430 should be: public static Complex operator *(Complex lhs, Complex rhs) { return new Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginery, lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary); }

Anonymous  Apr 19, 2011  Jul 29, 2011
Printed
Page 430
Bold code for overloaded * operator after first paragraph.

There are already two submitted confirmed errata for this calculation confirming that code in the book is wrong, the confirmed errata contradict each other. Additionally, assuming the calculation for imaginary number multiplication in the table on page 428 is correct, both of the confirmed errata are still wrong so far as I can see. Here is the code from the book (B), the code as given by Steven Gregory's submission on 28-Dec-2010 (S) and the code as given by an anonymous submitter on 19-Apr-2011 (A). The following code snippets are best viewed in a monospaced editor in order to see the differences. B: return new Complex(lhs.Real * rhs.Real + lhs.Imaginary * rhs.Real, lhs.Imaginary * rhs.Imaginary + lhs.Real * rhs.Imaginary); S: return new Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + rhs.Real * lhs.Imaginary); A: return new Complex(lhs.Real * rhs.Real + lhs.Imaginary * rhs.Imaginery, lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary); Returning to the table on page 428, the calculation for multiplication is given as "(( a * c - b * d) + (b * c + a * d)i)". If we simply substitute as follows... a = lhs.Real b = lhs.Imaginary c = rhs.Real d = rhs.Imaginary ...then that gives: (( lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary) + (lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary)i) Or, in terms of the code itself: return new Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary) Given that the book and at least one of the confirmed errata contain mistakes could someone please carefully check my logic and correct or remove any existing errata which are found to be incorrect, as at least one of them is regardless of whether I'm right or not. Thanks.

Note from the Author or Editor:
OK. Here is the definitive answer. The code should be: return new Complex(lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + lhs.Real * rhs.Imaginary); This will be updated in the next reprint.

Matt Dale  Jul 24, 2011  Jan 20, 2012
Printed
Page 431
top of page, command line screen shot

now that everyone has jumped on the complex number formula and coding errors, perhaps now the "Verify that the application displays the results shown" should be changed to show the results of a correct multiplication operation (I would suggest that the values should be (42 + 40i). In addition, perhaps the sample code for Complex.cs should be changed from return new Complex(lhs.Real * rhs.Real + lhs.Imaginary * rhs.Real, lhs.Imaginary * rhs.Imaginary + lhs.Real * rhs.Imaginary); to return new Complex (lhs.Real * rhs.Real - lhs.Imaginary * rhs.Imaginary, lhs.Imaginary * rhs.Real + rhs.Real * lhs.Imaginary);

Note from the Author or Editor:
The image at the top of page 431 needs to be changed to show the correct results. The result of the multiply operation should be: (42 + 40i)

Fritz Schoonover  Oct 30, 2011  Jan 20, 2012
Printed
Page 432
The "Important" note, just above step 5 of the exercise

In the Equals method, the statement that creates the Complex compare object should use the "as" keyword rather than "As". The full code sample should be: public override bool Equals(Object obj) { Complex compare = obj as Complex; if (compare != null) { return (this.Real == compare.Real) && (this.Imaginary == compare.Imaginary); } else { return false; } }

John Sharp
John Sharp
O'Reilly Author 
Jan 09, 2012  Jan 12, 2012
Printed, PDF
Page 435
2nd paragraph

the return statement in: public static implicit operator int (Hour from) { return this.value; } should be: return from.value; 'this'-keyword is not valid in a static method.

Note from the Author or Editor:
I concur. The complete code should be: struct Hour { ... public static implicit operator int(Hour from) { return from.value; } private int value; }

Raf  Aug 11, 2010  Jul 29, 2011
Printed
Page 447
Figure and final paragraph

In chapter 22 there seems to be a discrepancy between the figure which shows the button in the upper right of the form, and the XAML which says Margin="0,84,34,0" for the button properties. Entering those values puts the button flush against the left side of the form. For me, a correct set of values in VS 2010 is more like <Grid> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="374,40,0,0" Name="button1" VerticalAlignment="Top" Width="75" /> </Grid>

Note from the Author or Editor:
Although this is not critical, the reader's observation is correct. I suggest that we change the code for Step 6 to be: <Grid> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="374,40,0,0" Name="button1" VerticalAlignment="Top" Width="75" /> </Grid>

Ron Sipherd  Aug 07, 2010  Jul 29, 2011
Printed
Page 447
3rd sentence below the image.

The connectors show that the button is anchored to the top and right edges of the grid should read The connectors show that the button is anchored to the top and left edges of the grid

Note from the Author or Editor:
The reader is correct. The third sentence in the paragraph below the image should read: The connectors show that the button is anchored to the top and left edges of the grid.

Steven Gregory  Dec 29, 2010  Jul 29, 2011
Printed
Page 448
Last sentence of step 10

Also notice that the Margin property now specifies a nonzero value for the left margin should read: Also notice that the Margin property now specifies a nonzero value for the right margin

Note from the Author or Editor:
The reader is correct. The final sentence in step 10 on page 448 should read: Also notice that the Margin property now specifies a nonzero value for the right margin.

Steven Gregory  Dec 29, 2010  Jul 29, 2011
Printed
Page 469
Second sentence of step 9

In step 9, DateTime is a struct and not a class. The second sentence: You can do this by setting the Text property of the control. You can obtain the current date from the static Today method of the DateTime class. Should read: You can do this by setting the Text property of the control. You can obtain the current date from the static Today method of the DateTime struct.

John Sharp
John Sharp
O'Reilly Author 
Jan 09, 2012  Jan 20, 2012
Printed, PDF
Page 475
Step 4

The first line of Step 4 refers to the "memberFormClosing" method, but the following code block is for a method named "Window_Closing". It looks like "memberFormClosing" should be "Window_Closing".

Note from the Author or Editor:
The reader is correct. The code sample is correct, but the text at the start of step 4 should read: "Add the following statements shown in bold type to the Window_Closing method."

Harry Parker  Jul 12, 2011  Jul 29, 2011
Printed
Page 479
XAML code sample, lower half of page

On page 479 I think the XAML line for the menu which reads VerticalAlignment="Top" > should say VerticalAlignment="Top" /> Omitting the slash results in a syntax error.

Note from the Author or Editor:
The reader is correct. There is a missing "/" character in the code.

Ron Sipherd  Aug 15, 2010  Jul 29, 2011
Printed, PDF
Page 503
1st paragraph

Last sentence in the first paragraph (before code), it reads: "Notice that the for loop iterates through the List<string> collection rather than the the check boxes on the form:" The "for loop" should be "foreach loop"..?

Note from the Author or Editor:
The reader is correct. In the text in the first paragraph, the sentence starting: "Notice that the for loop ..." should be: "Notice tht the foreach loop ..."

Tomi Halonen  Dec 07, 2010  Jul 29, 2011
PDF
Page 518
bottom

I think it should be <ticketOrder:TicketOrder x:Key="orderData" />

Note from the Author or Editor:
In the code in step 1, the following line: <ticketOrder:Customer x:Key="orderData" /> should be: <ticketOrder:TicketOrder x:Key="orderData" />

jorge natalino  Nov 09, 2010  Jul 29, 2011
Printed, PDF
Page 519
Note at middle of page

The note reads: "Make sure you actually delete the contents of the foreName text box rather than just overtyping the text with spaces" Should that be "customerReference" rather than "foreName" ?

Note from the Author or Editor:
The reader is correct. The note should state "Make sure you actually delete the contents of the customerReference text box rather than just overtyping the text with spaces"

Dominic  Dec 22, 2012 
Printed
Page 521
Step 5, first code line

The first line of code reads "class Customer" where I think "class TicketOrder" was intended, as it reads in the completed solution. (More generally, I wonder if it is wise for the example to use similar names for different entities. The term "PrivilegeLevel" variously capitalized refers to an enumeration, a private variable, and a property; it works, but in a challenging chapter like #24 it seems to add an extra hurdle to comprehension; well to my comprehension anyway. I'm translating the solution to Visual Basic for my own benefit, so I used unique names which I found helped me figure out what was going on.)

Note from the Author or Editor:
The reader is correct. The instruction for Step 5 is correct, but the name of the class shown in the code fragment underneath is wrong. It should be TicketOrder and not Customer: class TicketOrder { ... <REST OF CODE EXACTLY AS SHOWN IN STEP 5> }

Ron Sipherd  Sep 06, 2010  Jul 29, 2011
PDF
Page 523
3rd

2. Add the PrivilegeLevelConverter class shown next to the end of the file, after the Customer class: I think it should be TicketOrder class

Note from the Author or Editor:
In Step 2, change the instruction: Add the PrivilegeLevelConverter class shown next to the end of the file, after the Customer class. to: Add the PrivilegeLevelConverter class shown next to the end of the file, after the TicketOrder class.

jorge natalino  Nov 09, 2010  Jul 29, 2011
Printed
Page 523
Step 3

The errata for this step is insufficient: it must be emphasized that it should be AFTER the TicketOrder class -- but within OrderTickets namespace. I placed the class definition at the end of the file -- thinking it was after the TicketOrder class -- and no errors or warnings till page 525, step 2 -- and it was a nightmare to figure out what the problem was. Even the Designer refused to open and additional errors appeared as well.

Note from the Author or Editor:
Noted. The PrivilegeLevelConverter class should be defined after the TicketOrder class but within the OrderTickets namespace.

Anonymous  Jan 03, 2013 
Printed, PDF
Page 525
Step 3, 2nd sentence

Not sure if this changes how the code behaves, but the instruction and the code sample following don't match. The sentence reads, "After the list of combo box items, add the XAML code shown next in bold type ...", but the emboldened code is BEFORE the list of combo box items. Changing "After" to "Before" will make the instruction agree with the code.

Note from the Author or Editor:
This is a minor point that makes no difference to the correctness of the code, but the reader is correct. The 2nd sentence of step 3 on page 525 should start: "Before the list of combo box items, ..."

Harry Parker  Jul 16, 2011  Jul 29, 2011
Printed, PDF
Page 526
Step 6, paragraph under the code, sentence 3

the sentence ", the GetBinding method retrieves the object bound to the Text property of the title combo box", should refer to the Text property of the privilegeLevel combo box.

Note from the Author or Editor:
On page 526, in the paragraph under step 6, the 3rd sentence should read: In this case, the GetBinding method retrievesthe object bound to the Text property of the privilegeLevel combo box.

Ralph M  Jun 03, 2013 
Printed
Page 529
under bullet 4

In this last exercise of chapter 24, I found a problem with one test I ran. 1) Pick valid values for the festival and customer reference. 2) Leave the privilege level at Standard. 3) Set the number of tickets to 5. 4) Purchase. That works fine with an error that makes sense, but: 5) Reduce the number of tickets to 2. 6) Purchase. Now, the privilege level is flagged. This seems to be because when TicketOrder.PrivilegeLevel is called, the number of tickets has not yet been updated, although it will be very soon. 7) Purchase, which is accepted. Being a rookie to this material, I do not know the best way to fix it. It seems very non-intuitive to the user of this program if it worked this way in production. I fixed it by changing the updates in bullet 4 to include a second call to privileveLevelBe.UpdateSource(). like this: eventBe.UpdateSource(); customerReferenceBe.UpdateSource(); privileveLevelBe.UpdateSource(); numberofTicketsBe.UpdateSource(); privileveLevelBe.UpdateSource();

Note from the Author or Editor:
The reader is correct. Due to the interdependence between the privilege level and the number of tickets, it is either necessary to check the privilege level before and after setting the number of tickets, or check the number of tickets before and after setting the privilege level. The reader's suggestion takes the former approach. The alternative would be to use the following code: eventBe.UpdateSource(); customerReferenceBe.UpdateSource(); numberofTicketsBe.UpdateSource(); privileveLevelBe.UpdateSource(); numberofTicketsBe.UpdateSource();

Jay Meyer  Oct 26, 2012 
Printed
Page 538
Bottom of page - Step 2 under Connect to the database

Step 2 reads: Create a new project called ReportOrders by using the Console Application template. Save it in the \Microsoft Press \Visual CSharp Step By Step \ Chapter 25 folder under your documents folder. This step cannot be completed, since the project by that name already exists. Also, the steps on following pages are already done in the Report.cs file.

Note from the Author or Editor:
The same issue arises on page 560 with the LINQOrders project. This is a small problem with the sample files provided on the CD. In the Chapter 25 folder, the existing LINQOrders and ReportOrders folders should be renamed as "LINQOrders - Complete" and "ReportOrders - Complete" prior to starting the exercises in this chapter.

hopmedic  Apr 23, 2011 
Printed, PDF
Page 554
2nd paragraph

In 2nd paragraph, the last sentence in parentheses (before code example): column name SupplierName should be SupplierID

Note from the Author or Editor:
The reader is correct. In the sentence before the code snippet at the end of the 1st paragraph in the section "Joining Tables and Creating Relationships", the reference to SupplierName should be SupplierID.

Tomi Halonen  Dec 11, 2010  Jul 29, 2011
Printed
Page 558
last paragraph

The example shown here causes the Products property of each Supplier entity to be populated as soon as the data for each Product entity is fetched... Should read: The example shown here causes the Products property of each Supplier entity to be populated as soon as the data for each Supplier entity is fetched...

Note from the Author or Editor:
The reader is correct. The offending sentence is in the middle of the final paragraph of page 558. It should read: "The example shown here causes the Products property of each Supplier entity to be populated as soon as the data for each Supplier entity is fetched rather than being deferred."

Anonymous  Sep 02, 2010  Jul 29, 2011
PDF
Page 587
bottom

Product newProduct = Product,CreateProduct(0, "Fried Bread", false); I think this statement should be Product newProduct = Product.CreateProduct(0, "Fried Bread", false);

Note from the Author or Editor:
This is a typo. In the code towards the bottom of page 587, the following statement: Product newProduct = Product,CreateProduct(0, "Fried Bread", false); Should be: Product newProduct = Product.CreateProduct(0, "Fried Bread", false);

jorge  Nov 13, 2010  Jul 29, 2011
Printed
Page 622
top of page and middle of page

There is only one for loop in the calculateData method after the code was move from the generateGraphData method. At the top of the page and in middle of page there is typo in two lines of code that plotXY, the (int)(y + (pixelWidth /2) should be changed in both lines to (pixelHeight /2).

Note from the Author or Editor:
The reader is correct. The following code statements: plotXY(data, (int)(-x + (pixelWidth / 2)), (int)(y + (pixelWidth / 2))); plotXY(data, (int)(x + (pixelWidth / 2)), (int)(y + (pixelWidth / 2))); Should be: plotXY(data, (int)(-x + (pixelWidth / 2)), (int)(y + (pixelHeight / 2))); plotXY(data, (int)(x + (pixelWidth / 2)), (int)(y + (pixelHeight / 2))); Note that these statements occur twice; near the top of the page, and in step 3 near the middle of the page.

Anonymous  Dec 09, 2010  Jul 29, 2011
Printed
Page 627
Tip in step 6

The code in the Tip is incorrect. The Parallel.Invoke construct automatically starts a new task for each action, so there is no need to use the Task.Factory.StartNew method (indeed doing so is wrong as the Parallel.Invoke construct then just waits for the tasks to start.) The code should be: Parallel.Invoke( () => generateGraphData(data, 0, pixelWidth / 8), () => generateGraphData(data, pixelWidth / 8, pixelWidth / 4), () => generateGraphData(data, pixelWidth / 4, pixelWidth * 3 / 8), () => generateGraphData(data, pixelWidth * 3 / 8, pixelWidth / 2) );

John Sharp
John Sharp
O'Reilly Author 
Jun 06, 2011  Jul 29, 2011
Printed
Page 633
last line

incorrect: CancellationToken cancellationToken = cancellationToken.Token; correction: CancellationToken cancellationToken = cancellationTokenSource.Token;

Note from the Author or Editor:
On page 633, the last line of code at the bottom of the page should be: CancellationToken cancellationToken = cancellationTokenSource.Token;

Adam C  May 01, 2013 
Printed
Page 634
start of code snippet at bottom of page

typo: a comma was used where a period is required incorrect: cancellationToken,Register(doAdditionalWork); correction: cancellationToken.Register(doAdditionalWork); Thanks for the great book. Adam

Note from the Author or Editor:
The first line of the code sample near the bottom of page 634 should be: cancellationToken.Register(doAdditionalWork);

Adam C  May 01, 2013 
PDF
Page 683
Last Code Block

public class Customer { public int _customerID; public int CustomerID { get { return this._customerID; } set { this._customerID = value; } } There is no point to having the property "CustomerID" apply to the already public field "_customerID" "_customerID" should have the access modifier "private" not "public".

Note from the Author or Editor:
This question actually relates to the 2012 and 2013 editions rather than the 2010 edition. On pages 673-674 of the 2013 edition, the fields with the names starting with an underscore character should ideally be private (as described in the note that accompanies the code) rather than public. The same applies on pages 685-686 of the 2012 edition. However, it is not a major problem and does not prevent the code from working.

Anonymous  Jan 18, 2014 
Printed
Page 693
Testing the application

Having moved from chapter to chapter using Visual C# 2010 Express, when I reached the point of testing the call to HowMuchWillItCost using Visual Web Developer 2010 Express, I received an error that the service experienced an internal error. I determined that the Northwind database could not be opened. I tried running Chapter 25's ReportOrders solution and experienced the same problem. I have determined that it is because in Chapter 26, we detached the Northwind DB from the user instance to be able to use the entity data model and we need to reattach it for this exercise. I suggest you add a note for the C# and Web Express edition users to attach the Northwind database prior to running the exercise.

Note from the Author or Editor:
The reader is correct. Ideally, we need to modify the note half way down page 693 as follows: Note: The Web services that you build in this chapter require access to the Northwind database. If you have not already done so, you can create this database by following the steps in the section "Creating the Database" in Chapter 25, "Querying Information in a Database". Additionally, if you have previously been using Visual C# 2010 Express, you cannot use the detatched version of the Northwind database for the exercises in this chapter. Instead, you should delete the Northwind.mdf and Northwind_log.ldf files from the C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSSQL\DATA folder and then rebuild the Northwind database by running the instwnd.sql script as described in Chapter 25.

Robert Lundin  Jul 11, 2011  Jul 29, 2011
Printed
Page 703
2nd paragraph point 2

....reads the unit price of the product *form* the database.... should this be "from"

Note from the Author or Editor:
This is a typo. In the 2nd paragraph in step 2 on page 703, the phrase: ....reads the unit price of the product form the database.... Should be: ....reads the unit price of the product from the database.... ("form" should be "from")

Anonymous  Dec 17, 2010  Jul 29, 2011
Printed
Page 707
point 5 first line

Add the GetProduct method definition shown next in bold to the *IProductService* interface.... this should be IProductDetails

Note from the Author or Editor:
The reader is correct. The instruction for step 5 should read: Add the GetProduct method definition shown next in bold to the IProductsDetails interface:

Anonymous  Dec 17, 2010  Jul 29, 2011
Printed
Page 707
point 6 2nd sentence

I'm working with visual C# 2010 express and visual web developer 2010 express. when i follow instructions to create IProductDetails.cs the ProductDetailsContracts.dll does not windup in the ProductDetailsContracts/bin/Debug folder but the ProductDetailsContracts/bin/Release folder also, following the steps up to step 10, c# 2010 express does not except the using System.Data.Linq until I add a System.Data.Linq to it, there is not a step that says to add this reference. when i try to run the productClient wcf and try either calculate cost or get product with all the "complete" files open I get error message saying "Error obtaining cost. There was no endpoint listening at http://localhost:4500/ProductInformationService/Service.svc that could accept the message." or "Error fetching productDetails. There was no endpoint listening at http://localhost:4600/ProductDetailsService/Service.svc/products/10 that could accept the message."

Note from the Author or Editor:
The first issue is due to a minor change that has occurred in the default behavior of VC# Express edition since the book was written (th bok was developed using the beta version of the software). You can change the location that VC# Express uses to build the ProductDetailsContracts.dll assembly by using the Build page in the ProductDetailsContracts project properties window, and changing the output path to bin\Debug\ (the default is bin\Release\) The second problem is due to a missing step - after step 6, there should be an instruction to add a reference to the System.Data.Linq assembly, as there was in the previous exercise. I suspect that the third problem is because the REST Web service is no longer running. If you are using Visual Web Developer, at the end of the exercise on page 711, ignore the instruction to close Internet Explorer and leave the project running in debug mode.

Anonymous  Dec 17, 2010