Microsoft Visual C# 2013 Step by Step

Errata for Microsoft Visual C# 2013 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
Other Digital Version
Location 116
Under code samples

The following link provided: http://aka.ms/VC2013SbS/files for me does not seem to open any webpage. I've tried directly pasting it into my browser (and different browsers - IE, Chrome) with the same 404 error popping up. Don't know if I am missing something obvious. Thanks for your help! -Patrick

Note from the Author or Editor:
The files have not yet been hosted. They should be there shortly.

Patrick Kennedy  Nov 18, 2013 
Printed, PDF
Page Page xxiv
Code Samples section (3 occurences)

The Code Samples section refers to the file C#_SBS.zip. However, the name of the download containing the code files is actually C_Sharp_SBS.zip

John Sharp
John Sharp
O'Reilly Author 
Nov 22, 2013 
Printed, Other Digital Version
Page Pratice Files + Code
2630 8.Locate the compareClick method, which should look like this:

Error in downloaded code files. This needs to be .SelectedDate.Value instead of .DisplayDate private void compareClick(object sender, RoutedEventArgs e) { int diff = dateCompare(firstDate.DisplayDate, secondDate.DisplayDate);

Note from the Author or Editor:
Unfortunately, the uploaded sample files for this chapter are the wrong version (they are a preliminary version that were changed, although I seem to have mixed up the versions - entirely my fault). The first line in the compareClick method should be exactly as reproduced in the book: int diff = dateCompare(first, second); The problem is that the DatePicker controls in Windows 7 and Windows 8.1 expose different properties for accessing the current date. I hid these differences by using two properties named first and second in the MainWindow class, which is what the code in the book uses. For interest, these properties look like this in Windows 7: #region Conversion properties to cater for the differences between the DatePicker control in Windows 7 and Windows 8.1 private DateTime first { get { return this.firstDate.SelectedDate.GetValueOrDefault(this.firstDate.DisplayDate); } } private DateTime second { get { return this.secondDate.SelectedDate.GetValueOrDefault(this.secondDate.DisplayDate); } } #endregion In Windows 8.1 they look like this: #region Conversion properties to cater for the differences between the DatePicker control in Windows 7 and Windows 8.1 private DateTime first { get { return this.firstDate.Date.LocalDateTime; } } private DateTime second { get { return this.secondDate.Date.LocalDateTime; } } #endregion It is not actually necessary to understand how these properties work (properties are covered later in the book), but I thought I ought to explain what had happened here. I will ask to have the latest version of the code uploaded, so hopefully this problem should not confuse readers in the future.

Walter Pidwarko  Dec 14, 2013 
Other Digital Version
Location 2707
1st paragraph

Built-in method for comparing dates is called CompareTo not Compare

Note from the Author or Editor:
On page 105, in the box titled "Comparing dates in real-world applications", the phrase, the reference to the Compare method (5 lines from the end of the box) should be CompareTo.

Walter Pidwarko  Dec 14, 2013 
Printed
Page xxiv
middle of page

I downloaded the code files but can not extract the zip file. I receive an error about the path name is too long.xxiv

Note from the Author or Editor:
An extra folder level (C_Sharp_SBS) seems to have crept in to the file paths in the zip, and if you do not extract the files directly into the Documents folder the names of some of the generated .pp files for the later exercises cause this error. These files are not critical. However, to avoid this problem, open the ZIP file after downloading it, move to the C_Sharp_SBS folder in the ZIP, and then drag the Microsoft Press folder to your Documents folder. This should extract the files and put them in the correct place as documented by the exercises in the book, and hopefully the path names should no longer be too long.

Anonymous  Dec 30, 2013 
Printed
Page xxv
2nd paragraph

Page xxv in the Introduction states that the sample code should have folders for each chapter with the suffix "- Complete", but no such folders exist.

Note from the Author or Editor:
We are uploading a new version of the code samples with this issue rectified.

Anonymous  Feb 06, 2014 
Printed
Page 32
bottom third

typeof(GraphWindow) should be typeof(MainPage) as follows (and navigation error handling is now a separate method--not just an if statement) if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active

Note from the Author or Editor:
This was a "cut and paste" typo. The statement 12 lines from the bottom of the page, should be: if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))

Anonymous  Jan 29, 2014 
Printed
Page 36
first 4 lines

get warning that await not used with async method either explain to the reader or change the code to include async and await as follows: private async void okClick(object sender, RoutedEventArgs e) { MessageDialog msg = new MessageDialog("Hello " + userName.Text); await msg.ShowAsync(); }

Note from the Author or Editor:
It is probably worth adding the following note at the end of step 5 at the top of page 36: This code will display a warning concerning the use of an asynchronous method when it is compiled. You do not have to be concerned about this warning. Asynchronous methods are explained more fully in Chapter 24.

Anonymous  Jan 29, 2014 
PDF
Page 71
step 3

You mentioned 2 times that Int32 is a class, while it is a struct.

Note from the Author or Editor:
We had a bit of a debate about this when we wrote this step of the exercise. Int32 is a struct (as documented and referenced on page 213 later in the book), but at this stage structs have not been introduced. We originally used the term "type", but it got edited into "class". In this paragraph, the two instances of the word "class" should be changed to "type".

Moataz  Dec 20, 2013 
Other Digital Version
90
Item #9 in the To Do code 2nd case statement, 4 lines down from "above the default label:"

Hi, I wrote a couple of note to different people in the even my notes were ignored. It is on page 90 of the Nook eBook from Barnes and Noble. Page: 90, Chapter 4. Item 9. The Chapter is called: “ Following the switch statement rules” The application is "nook for PC" and as I said it was from Barnes and Nobel. machine Configuration": Windows 8.1 upgrade from Win 8.0. Intel i7 Quad core (x64) Tools: Microsoft visual Studio 2013 Ultimate (trial) The Error in print copy the code: ‘&' : The first error reads in the tool tips: Newline in constant. My 1st correction >>> '&'' : 2nd correction >>> ‘&'' : 3rd correction >>> ‘&&x0027; : 4th >>> ‘&&x0027;' : 5th >>> ‘&' : and so on - All my corrections resulted in the same error: To Many characters in character literal. Please let me know what you find: Harvey L Wright Lubbock, TX

Note from the Author or Editor:
It looks like there are some formatting issues with the Nook edition of the book. The completed code for the CopyOne method should look like this: private void copyOne(char current) { switch (current) { case '<': target.Text += "&lt;"; break; case '>': target.Text += "&gt;"; break; case '&': target.Text += "&amp;"; break; case '\"': target.Text += "&#34;"; break; case '\'': target.Text += "&#39;"; break; default: target.Text += current; break; } } The formatting process for the Nook edition seems to have mangled some of the text sequences. This code is correct in the printed edition and PDF edition of the book – the steps that get the user to write this code should look like this: 8. Add the following statements shown in bold to the switch statement after the opening brace for the statement and directly before the default label: switch (current) { case '<' : target.Text += "&lt;"; break; default: target.Text += current; break; } If the current character being copied is a left angle bracket (<), the preceding code appends the string “&lt;“ to the text being output in its place. 9. Add the following statements to the switch statement after the break statement you have just added and above the default label: case '>' : target.Text += "&gt;"; break; case '&' : target.Text += "&amp;"; break; case '\"' : target.Text += "&#34;"; break; case '\'' : target.Text += "&#39;"; break;

Harvey Wright  Jan 10, 2014 
Printed
Page 153
second line

Text assumes no radio button has IsChecked = True, but the "addition" radio button in the sample code has IsChecked = True. So, you have to turn that off in MainWindow.xaml beforehand for the exercise to make sense.

Note from the Author or Editor:
We are uploading a new version of the code samples with this issue rectified.

Anonymous  Feb 01, 2014 
Other Digital Version
221
4th Paragraph (item 10.)

... ... private void drawingCanvas_RightTapped(object sender, HoldingRoutedEventArgs e) ... When creating drawingCanvas_RightTapped event handler VS2013 update 1 (Windows 8.1 newest SP); Visual Studio creates: private void drawingCanvas_RightTapped(object sender, RightTappedRoutedEventArgs e) instead of: private void drawingCanvas_RightTapped(object sender, HoldingRoutedEventArgs e) When I correct "RightTappedRoutedEventArgs e" and change it to "HoldingRoutedEventArgs e" I get a runtime error: No overload for 'drawingCanvas_RightTapped' matches delegate 'Windows.UI.Xaml.Input.RightTappedEventHandler'

Note from the Author or Editor:
This seems to be one of those items that changed between the "early" and "final" releases of VS 2013. The type of the parameter should be RightTappedRoutedEventArgs as generated by Visual Studio.

Anonymous  Feb 19, 2014 
PDF
Page 301,303
bottom,top

Colors is a class, not enum.

Note from the Author or Editor:
The final paragraph at the bottom of page 301 should be: "The Windows.UI namespace contains the definition of the Colors class which you will use when you set the color of a shape as it is drawn. In WPF, this class is defined in the System.Windows.Media namespace, which is already referenced by the DrawingPad.xml file" The following sentence (in brackets) at the top of page 303 should read: "(The Colors class is provided as part of the .NET Framework)"

Moataz  Dec 20, 2013 
PDF
Page 305
top

2 semi-colons after 2 methods implementation

Note from the Author or Editor:
The semi-colon after the closing "}" for the two implementations of the ChewGrass methods (for the Horse and Sheep classes) should be removed.

Moataz  Dec 20, 2013 
Printed
Page 329-336
all

The sample code for Chap 14 is already completed.

Note from the Author or Editor:
We are uploading a new version of the code samples with this issue rectified.

Anonymous  Feb 06, 2014 
PDF
Page 445
2nd paragraph

you said: IEnumerator<T> class* containing a Current method** * interface ** property

Note from the Author or Editor:
The second sentence of the second paragraph on page 445 should read: "The compiler uses this code to generate an implementation of the IEnumerator<T> interface containing a Current property and a MoveNext method."

Moataz  Dec 20, 2013 
PDF
Page 449
top

IEnumerator<TItem> GetEnumerator(){} you must either implement this method explicitly or qualify it as public.

Note from the Author or Editor:
This is an oversight caused by oversimplifying the code shown in the exercises (the code in the exercises is correct). In the Do This column in the first row of the Quick reference table, the code should be: public class Tree<TItem> : IEnumerable<TItem> { ... IEnumerator<TItem> IEnumerable<TItem>.GetEnumerator() { ... } } Similarly, in the third row, the code sample should be: IEnumerator<TItem> IEnumerable<TItem>.GetEnumerator() { for (...) { yield return ... } } Also, in the second row, the code for the Current and MoveNext members should reference the IEnumerator<TItem> type: public class TreeEnumerator<TItem> : IEnumerator<TItem> { ... TItem IEnumerator<TItem>.Current { get { ... } } bool IEnumerator<TItem>.MoveNext() { ... } }

Moataz  Dec 20, 2013 
PDF
Page 506
step 7

a quote from the book: "LINQ provides generic and nongeneric versions of the ToList and ToArray methods." I didn't find any nongeneric versions. Any generic method can be called with/without <>. in other words: var allEmployees = from e in empTree.ToList<Employee>( ) select e; is same as: var allEmployees = from e in empTree.ToList( ) select e;

Note from the Author or Editor:
The paragraph under the code in Step 7 is outdated and refers to an older version of the LINQ library that predates the use of var and type inference. The entire paragraph should be removed.

Moataz  Dec 18, 2013 
Printed
Page 679
whole page

Both images on p. 679 show the "title" ComboBox populated with bound data, but the steps on p.677 postpone how to do data binding for the ComboBox until p.684. The images on p. 679 should show the ComboBox as empty.

Note from the Author or Editor:
The reader is correct. In the next edition, the images on page 679 should show the Title combo box empty

Anonymous  Feb 15, 2014 
Printed
Page 726
after step 14

Text does not mention "Choose Data Source" wizard page. Step14a should be "On the Choose Data Source page, select SQL Server."

Note from the Author or Editor:
Unfortunately, this is one of the issues with the stateful nature of this wizard. The first time you run this wizard, the Choose Data Source page appears, but on subsequent runs Visual Studio remembers your choice and goes directly to the Connection Properties page. I will add a note about this in the next edition of the book.

Anonymous  Feb 15, 2014