C#

The Bonus Site for C# 2008 For Dummies
csharp102.info

Errata: Known Errors in C# 2008 For Dummies

(For the errata for the C# 2010 All-In-One For Dummies book, see csharpfordummies.net.)

When I got hold of my first copy of the published book, sure enough, I found the requisite goofs. I'll list them here and later add any that my astute readers discover.

I apologize for the inconvenience these errors will cause you - but at least you have the correct information on this page. I've categorized the errors so you can focus first on the most substantive ones. The first section is errors from the pages of the book. The second section is errors in the example code. And the third section is errors in the bonus chapters or articles.

The final section on this page is a set of Tips & Techniques that can be useful.

If you spot an apparent error, please look in these pages before you report the error. You can use this link to Report Errors on the Site or in the Book (or in the example code).

NEW: As of 4-21-08, I'm dating entries to help you locate what's new. Dates will look like

[4-21-08].

If you're looking for help with a balky program of your own, please try Microsoft's C# site, the C# Forum, or other Web information sources before emailing the authors. We love to help, but please keep in mind that we have too many irons in the fire to be a Help Desk.

Errors in the Book's Print Pages

  • Page 3, last line of the first paragraph. The reference to Bonus Chapter 6 should be to Bonus Chapter 5.

  • Page 6, under "About the Web site." I missed changing this paragraph after we decided to put the bonus materials on a Web site rather than on a CD-ROM. The paragraph should read as follows:

    The Web site contains a host of goodies. First, you find an expanded collection of all the source code from this book. Second, you find seven additional bonus chapters. Finally, you find a collection of resources. These include a Frequently Asked Questions (FAQ) page, a variety of bonus articles plus references to useful books and articles you can find elsewhere, and links to several very useful utility programs, such as SharpDevelop, NUnit, and Reflector.
  • Page 6, under "About the Web site." I missed changing this paragraph after we decided to put the bonus materials on a Web site rather than on a CD-ROM. The paragraph should read as follows:

    The Web site contains a host of goodies. First, you find an expanded collection of all the source code from this book. Second, you find seven additional bonus chapters. Finally, you find a collection of resources. These include a Frequently Asked Questions (FAQ) page, a variety of bonus articles plus references to useful books and articles you can find elsewhere, and links to several very useful utility programs, such as SharpDevelop, NUnit, and Reflector.
  • Page 14, next-to-last line on the page. The reference to Bonus Chapter 6 should be to Bonus Chapter 5.

  • Page 17, list item b, last sentence (in parentheses). Change the following:

    (The directory may already exist if you've installed the example programs from the Web site.)

    to the following:

    (You need to create the following directory: C:\C#Programs. Then install the programs there from the Web site.)
  • Page 20, first line on page. Change DOS to Windows. (DOS died a while back--it's all Windows now.)

  • Page 21, first line of code in the upper code example. The first line of code here should be in boldface type.

  • (Error submitted on 4/2/08) Page 31, the BigInteger section. Well, this one's a bit of a doozy. The C# specification document listed BigInteger as one of the new features, so I dutifully wrote about it -- but didn't really check it out or try using it. What use do I have for such a beast? What use do you have? Most For Dummies readers won't have ANY use for it in all likelihood. As it turns out, there is a BigInteger class, but it's hidden away inside the cryptography library in the .NET Framework libraries. Not public, not directly usable in C#. There is a sort of twisted back-door way to get at it, by using a companion .NET language called J# (a part of Visual Studio 2008 Standard and above) -- which does make a big integer implementation available. You have to include a J# library in your C# program to use it. So it is there, sort of. Anyway, my apologies for not having checked it out more carefully before writing about it. For more information, you can check it out at msdn2.microsoft.com/en-us/magazine/cc163696.aspx.

  • Page 36, first line in the paragraph below the code example. The word second should be first.

  • Page 64, first line of second paragraph below the code. This line should read: The example program uses the ReadLine() command to read in what the user ...

  • Page 86, just before the heading "Don't goto pieces." I should have added the following short paragraph:

    You can nest if and switch statements within each other too.
  • Page 94, next-to-last line in the gray sidebar. The reference to Bonus Chapter 6 should be to Bonus Chapter 5.

  • Page 99, in the listing of the BubbleSortArray program, 17 lines down from the top of page 99. The statement assigning the planets array to the sortedNames array before sorting is a coding error--here's the line: string[] sortedNames = planets;

  • This line does NOT copy the contents of planets into sortedNames, as I indicated. Instead, it just points the sortedNames array reference to the planets reference. Both arrays point to the same data. Thus when I sort sortedNames, I sort both arrays in effect. Not what I intended. What I needed to do was use the Array.CopyTo() method to copy planets into sortedNames. The corrected code looks like the following:

    string[] sortedNames = new string[planets.Length];

    planets.CopyTo(sortedNames, 0);

    Array.Sort(sortedNames);

    This creates the sortedNames array, then copies planets to sortedNames, and sorts sortedNames. The planets array is not sorted--which is what I intended.

    Thanks to reader Brian Ripley for this one.

  • Page 105, line 4 of the paragraph titled "Going generic." The reference to Bonus Chapter 8 should be to Bonus Chapter 6.

  • Page 106, fourth paragraph. There should be an "On the Web" icon by this paragraph, which begins "The ListCollection...."

  • Page 106, first block of code on the page. All references to 'sList' should be to 'nameList'. REPORTED BY A SHARP-EYED READER.

  • Page 110, line 2 in the first paragraph, following the first code fragment. The Help search instruction should read "Look up dictionary in the Help Index. This gets you to the entry 'Dictionary(Of TKey, TValue)'. Click the 'initializing' entry under that item." (Note that this is Visual Basic syntax, but it gets you to C# information too.)

  • Page 116, last line on the page. The reference to Bonus Chapter 7 should be to Bonus Chapter 6.

  • Page 118, 3rd line on the page. It would be helpful to note that Bonus Chapter 4 is on this Web site.

  • Page 171, Figure 8-1. The notation "Output(funcString)" should read "Output(someString)" as it appears in the surrounding text.

  • Page 172, first paragraph. The Bonus Chapter 5 referred to was dropped at the last minute and its topics parceled out to a set of articles. You can find the information referred to in this paragraph in an article on this Web site titled "Passing arguments to a program." On the Home page, click Articles.

  • Page 145, last paragraph. The topic in Bonus Chapter 5 is now an article on this site, titled "Converting Between Byte and Char Arrays." On the Home page, click the Articles link.

  • Page 225, first paragraph. The phrase "your Web site" should be "my Web site." You may not even have one!

  • Page 239, last paragraph before the heading that begins "Initializing an object ...." The reference to Bonus Chapter 6 should be to Bonus Chapter 5.

  • Page 266, parenthetic sentence below first code example. The reference to Bonus Chapter 7 should be to Bonus Chapter 6.

  • Page 267, 3rd line of program output near bottom of page. The code above that output actually prints "now creating...," with a lowercase 'n,' not "Now creating...," with an uppercase 'N.'

  • Page 268, first line of output section at bottom of page. The line printed is actually "Invoking SubClass() default".

  • Page 273, Figure 12-1. The middle line in the figure has an extraneous parenthesis. Delete the middle one, ')'.

  • Page 309, second block of code. The return statement in the CreateRecorder method is missing a required cast. Since the method returns an IRecordable, not a Pen, the newly created Pen must be cast to an IRecordable. The code should look like this:

    if(recorderType == "Pen") return (IRecordable)new Pen();
  • Page 310, next-to-last line of first paragraph in the section "Using C#'s predefined interface types." The reference to Bonus Chapter 8 should be to Bonus Chapter 6.

  • Page 312, first line of code on the page. The Console.WriteLine call is missing a quote mark on its format string:

    "{0}, disp.Display()

    should be

    "{0}", disp.Display()

    Page 319, Figure 14-1. In the uppermost box of the diagram, "iPet" should be "IPet" with a capital I.

  • Page 319, second paragraph below Figure 14-1. You should see an On the Web icon next to this paragraph. [4-21-08]

  • Page 336, last paragraph before "Pass me the code ...." The reference to Bonus Chapter 8 should be to Bonus Chapter 6.

  • Page 357, line 3 of the paragraph just before the one marked with a Remember icon. The reference to Bonus Chapter 7 should be to Bonus Chapter 6.

  • Page 361, first paragraph. Note that the "Extra Example 6" referred to is in the LambdaExamples program on this Web site.

  • Page 372, short paragraph following the one marked with a Tip icon. The phrase "from the following array" should read "from the given array."

  • Page 374, first item in the bulleted list--the Grouping paragraph. The second sentence makes better sense if you insert a dash or colon between "size" and "all customers".

  • Page 375, last paragraph. The reference to Bonus Chapter 8 should be to Bonus Chapter 7.

  • Page 376, last paragraph before the heading "What can I do ...." The reference to Bonus Chapter 7 should be to Bonus Chapter 6.

  • Page 376, last bullet item at the bottom of the page. The word "alphabetized" should be "ordered".

  • Page 396, second paragraph, just before the heading "What's inside ...." The reference to Bonus Chapter 7 should be to Bonus Chapter 6.

  • Page 401, last paragraph. Instead of being in Bonus Chapter 5, the example mentioned is in the article "Querying an Object As a Collection with LINQ" on this Web site. Click the Articles link on the Home page.

  • Chapter 10 should appear as part of Part IV, Object-Oriented Programming, rather than Part III, Using Objects. You see this error in the Table of Contents and later in the book.

Errors in the Example Code for C# 2008 For Dummies

BubbleSortArray Program, Chapter 5. A reader reports a coding error in the BubbleSortArray program listed on pages 98-100 in the book. The error is in the Program.cs file. See the Page 99 writeup in Book Errors for details.

Errors in the Bonus Chapters or Articles

  • In the article "Enumerating the Charms of the Enum," page 6, last paragraph on the page (marked Code Example), refers to code "on the CD." There is no CD in this edition. All articles and their code are on this Web site. The paragraph should read:

    The EnumFun example available with the download for this article shows off some of enum's many talents, including using enums in if and switch....

Tips and Techniques

The following tips and techniques are things I wish I had gotten into the book but didn't. These will save you time or add to your programmer's tool kit.

  • Commenting Out Lines of Code

    Page 162, paragraph 6, refers to "commenting out" some lines of code. It would be helpful here to explain the idea of "commenting out" lines of code. Often you need to remove lines of code, but you'd rather not just delete them. It's common practice for programmers to turn those lines into C# comments, preceded by "//". Visual Studio helps with this by providing a toolbar button called "Comment out the selected lines. (Ctrl+E,C)". The button looks like several lines of code in black, with several lines shown as being commented out, in blue. There's also an adjacent button to "uncomment" lines. To comment out lines, select the lines in the C# editor, then click the comment-out button. To uncomment, select the lines, then click the uncomment button.

  • Method Signatures

    Page 167, item 3 in the list. It would be helpful to define the term "signature" mentioned here. A method's signature consists of its name, its return type (or void), and the types of its parameters.

Errors on This Web Site

So far, no errors have been reported on the site yet except for occasional broken links, which I simply fix rather than adding them to the error list here.