Errata

Programming C# 3.0

Errata for Programming C# 3.0

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
12.2.2
Example 12-1. Publish and subscribe with delegates

Method Name "SecondChanged" conflicts with prior delegate instance of the same name:

protected virtual void SecondChanged(TimeInfoEventArgs e)
{
if (SecondChanged != null)
{
SecondChanged(this, e);
}
}

Does not compile under Visual Studio 2008. Changing the method name and it's call repairs the problem (I used "SecondChange").

BTW, when reading books Online, I cannot determine a "page number" so I used the Section Number

Anonymous  Oct 28, 2008 
Printed Page 21
Numeric types table

The "Integral-unsigned" and "Integral-unsigned" headers in the table have been swapped.

Anonymous   
Printed Page 22
Table 3-1

All the terms in the Type column should *not* be capitalized: Byte should be byte, Char should be char, etc. decimal is the only type which is correctly (not) capitalized.

Richard Albury  May 23, 2009 
Printed Page 36
halfway down the page

The second if/else block contains the line:

valueTwo = valueOne + 1;

this was changed from:

valueTwo = valueOne++;

in the 3rd edition of the book (which I also own).

The 3rd edition's output matches the output presented in both books. The 5th edition's does not.

3rd: ValueOne: 31 ValueTwo: 30
5th: ValueOne: 30 ValueTwo: 31

Anonymous   
Printed Page 37
First program output

Setting valueTwo to valueOne value,
and incrementing valueOne

ValueOne: 31 ValueTwo: 30

should be

ValueOne: 30 ValueTwo: 31 - because valueTwo is assigned to valueOne + 1 in the second conditional
test in book.

Anonymous   
Printed Page 41
First paragraph, last sentence

The sentence "If you uncomment WriteLine() under LiberalRepublican, this program won't compile." Should be changed to "If you uncomment WriteLine() under ConservativeRepublican, this program won't compile."

Vinnie Cardona  Apr 29, 2009 
PDF Page 63
3rd code snippet

The following code:
ListBox myListBox; // instantiate a ListBox object
did not instantiate the ListBox object because C# compiler will set myListBox null if 'new' operator is ommitted.
So it should be like this:
ListBox myListBox = new ListBox(); // instantiate a ListBox object

Anonymous  Dec 03, 2008 
PDF Page 79
1st paragraph

This book says:
Thus, if you want to initialize a static member, you must provide an explicit initializer.
but static member is initializable in the static constructor.
So it should be like this:
(snip) you must provide an explicit initializer, or initialize it inside its static constructor.

Anonymous  Dec 03, 2008 
Printed Page 82
Example 4-6.

using System.Drawing;

Compiler throws error when using Visual Studio 2008 C# Expression Edition. The authors have given
no clue if System.Drawing is not a default accessible namespace and needs to be imported or
referenced.

Anonymous   
Printed Page 90
public class Tester, first Time object instance

Erroneous code is

Time t1 = new Time(currentTime);
t.DisplayCurrentTime(); // error that "t" should be "t1"

Need to make the code

Time t1 = new Time(currentTime);
t1.DisplayCurrentTime();

Anonymous   
Printed Page 93
public int Hour definition

No comment is made in text about capitalizing the property Hour vs lowercase for private member
variable hour - don't know if this is standard practice to maintain same name but differ only in
case but it would be worth commenting on in text - particularly for people like me who just copied
code from earlier example, then got stack overflows in DisplayCurrentTime, etc. when "Hour" used
instead of "hour" - good OJT in the importance of case, though.

Anonymous   
Printed Page 104
Control constructor

typos in case, should be

this.Top = top;
this.Left = left;

Does not compile otherwise

Anonymous   
Printed Page 104
DrawWindow() function for Control class

the function definition should have the properties Top and Left capitalized as in

Console.Writeline( "Control: drawing Control at {0}, {1}",
Top, Left );

will not compile otherwise.

Anonymous   
Printed Page 105
DrawWindow() function for Button class

the function definition should have the properties Top and Left capitalized as in

Console.Writeline( "Drawing at button at {0}, {1}
",
Top, Left );

will not compile otherwise.

Anonymous   
Printed Page 106
Example in Calling Base Class Constructors

last line of example in this section does NOT match program

base(theTop, theLeft) // call base constructor

in program text given on page 104 the line reads

base(top, left) // call base constructor

Anonymous   
Printed Page 114
DisplayValue method in class Program

Console.Writeline statement is missing closing parenthesis

Anonymous   
Printed Page 130
first line of code

there are 14 reviews of this book at Amazon - almost all of them say this book is many errors. Why is the eratta for this book only one page? Someone is not doing their job.

Anonymous  Jun 19, 2011 
Printed Page 153
Second to last and third to last paragraphs

The book incorrectly states that Main() invokes the Cat.HowManyCats() static method. The static method is invoked from Run(), not Main().

This book is excellent, and is especially good when teamed up with Visual C++ 2008 from Microsoft. As an ex-C++ programmer, I find the book a good refresher and also a good point of departure for learning the differences between C++ and C#. I'm 58, but I like C# more than C++ (especially the type-safe and garbage collection features). Who says you can't teach an old Dog() new tricks?

Eric Bank  Mar 16, 2009 
Printed Page 186-187
Table 9-2 spanning pp 186-87

The Interface item "IColletion<T>" is listed twice in Table 9-2 with two different Purpose
explanations. I believe the Purpose given for the first instance of "ICollection<T>" in the table
is correct, but the Purpose given for the second instance implies, to me, that the intended
Interface item should not be "ICollection<T>", but some other Interface entity. I'm just not sure
what was intended.

Anonymous   
Printed Page 195
Table 9-3, last line

Table 9-3 lists methods of List<T>. Last method is TrimToSize(), but List class does not have that method.

Anonymous   
Printed Page 196
Bottom of page

This is in the 5th Edition:

The book states:
The default capacity is eight. When you add the 17th element, the capacity is automatically doubled to 16.
Shouldn't this read, when you add the 9th element, the capacity is automatically doubled to 16?

Then the book continues:
If you change the for loop to:
for (int i = 0; i < 9; i++)
...
The output given displays 17 elements. Based on the code, I would expect the output to contain only 9 elements.

Carol  Aug 25, 2009 
PDF Page 249
Example 11-4 code block

Example 11-4 has three errors.

First Console.WriteLine argument lacks the second double-quote.
It should be:
Console.WriteLine(
"ArithmeticException caught!");

Next, the second keyword "Catch" should be "catch".
At last, the second Console.WriteLine method name is wrong (Write"l"ine).

Yukitoshi Suzuki  Dec 06, 2008 
258
2nd class 4th and 5th objects

In your code and in the explanation of the code you create a function and an object using the same name SecondChanged (public SecondChangeHandler SecondChanged; and protected virtual void SecondChanged(TimeInfoEventArgs e) ).

The problem is is that this code in uncompilable and creates confusion as to what the programmer was trying to make a reference to when calling either one of these objects later on in the code or your description/explanation of the code.

Anonymous  Feb 27, 2009 
258/259
at botton of 258 and 2/3 the way down on 259

TimeInfoEventArgs.cs(43,30): error CS0102: The type 'EventsWithDelegates.Clock' already contains a definition for 'SecondChanged'
TimeInfoEventArgs.cs(41,34): (Location of symbol related to previous error)


In both the Book and on Safari had the same code but I downloaded the examples and discovered the work On had been added to SecondChanged.


in Clock:
protected virtual void OnSecondChanged(TimeInfoEventArgs e)


in Run: OnSecondChanged(timeInformation);

Herb Morriss  Feb 15, 2010 
Printed Page 262
2nd paragraph

Original text reads "...this delegate... takes two arguments: the first of type void..."

However, in the example, the first argument is of type object.

Bob Lidral  Mar 22, 2009 
Printed Page 266-271
Multiple

The text continually refers to the VIRTUAL FUNCTION OnSecondChange as the DELEGATE INSTANCE from
the preceding example. I believe the delegate instance SecondChanged is actually intended. This
mistake is made multiple times (consistently) over the 5 pages identified above and was very
confusing until I realized that this was a typo. Hopefully I am not mistaken, as I have continued
my learning with the assumption that this is a typo.

Anonymous   
Printed Page 266
Example code segments starting with "The Danger with Delegates"

In the original example, the event is named "OnSecondChanged". In the text and sample code starting on page 266, the final "d" has been dropped from the name so it becomes "OnSecondChange".

Bob Lidral  Mar 22, 2009 
PDF Page 266
code snippet at beginning of 'The Danger with Delegates'

The code and discussion from this point thru the section called 'The event Keyword' on pages 267-268 refer to a method called 'OnSecondChange' that does not exist in the code sample on pages 259 thru 262. I think it should instead refer to 'SecondChanged'.

Anonymous  Sep 24, 2009 
Printed Page 267
Last couple of code snippets

Not consistent with the program listing on previous pages and the following page (p. 268).

Change:

public event SecondChangeHandler OnSecondChange;

to:

public event SecondChangeHandler SecondChanged;

Anonymous   
Printed Page 267
Lines 5, 7, and 8 from the bottom

Replace all three instances of OnSecondChange with SecondChanged.

Hong Quach  Mar 26, 2009 
Printed Page 271
Examples in "Anonymous Methods" section

Why are some items in boldface in the example?

Bob Lidral  Mar 22, 2009 
PDF Page 296
3rd paragraph

This book says:
You can't use fully qualified extension method names as you do with a normal method.
but we can invoke the extension method with fully qualified name as a normal method like below (you have written in p298):
System.Linq.Enumerable.Where(names, n => n.StartsWith("D"));
so it should be "can use" rather than "can't use".

Anonymous  Dec 05, 2008 
Printed Page 304
2nd section, 1st paragraph

The text says: "HTML was derived from the Structured Query Markup Language (SQML)".

SQML does not exist. HTML is derived from SGML: Standard Generalized Markup Language.

thoover83  Jan 16, 2009 
Printed Page 314

I downloaded the examples from the O'Reilly web site.

The code for Example 14-3 in the 5th edition is significantly different from the code in the download.

CreateCustomerList() uses completely different names.

"static void main" from the downloaded code omits various WriteLine statements, in addition to using the different names.

Made it much more difficult to execute the code in the book and compare the outputs.

Bob Gerstmyer  Feb 11, 2010 
PDF Page 316
Output result for example14-2

Output result for example 14-2 has two mistakes.

First, output after "Search using node values..." duplicates the following:
SelectSingleNode("descendant::EmailAddress[text() = 'dAdams@foo.com']")...
<EmailAddress>dAdams@foo.com</EmailAddress>
but the second one should be:
SelectSingleNode("descendant::Customer[EmailAddress = 'dAdams@foo.com']")...
<Customer FirstName="Douglas" LastName="Adams"><EmailAddress>dAdams@foo.com</EmailAddress></Customer>

Next, the second last output also duplicated.

Yukitoshi Suzuki  Dec 06, 2008 
Printed Page 349
Example 15-2 Line 18

The code listing reads:
Customer donna = dc.Customers.Single(c => c.FirstName == "Donna");");

It appears that the last three characters of the line -- "); -- were repeated as they do not make any sense in the syntax of the code.

Anonymous   
PDF Page 351
3rd paragraph

This book said:
If there is more than one customer with that specific first name, only the first customer record is returned:
In fact, InvalidOperationException will be thrown if there is not exactly one element in the sequence.
http://msdn.microsoft.com/en-us/library/system.linq.queryable.single.aspx

Yukitoshi Suzuki  Jan 30, 2009 
Printed Page 375

Example 16-1 does not contain any references to the listbox as described in paragraph above
nor on the bottom of page 377.

Anonymous   
Printed Page 417
List of images

Here are the correct URI values for the photos. Without these, the application does nothing and gives no error messages.

<local:Images x:Key="Presidents">
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/1gw_header_sm.jpg"
Name="George Washington" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/2ja_header_sm.jpg"
Name="John Adams" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/3tj_header_sm.jpg"
Name="Thomas Jefferson" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/4jm_header_sm.jpg"
Name="James Madison" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/5jm_header.jpg"
Name="James Monroe" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/6ja_header_sm.jpg"
Name="John Quincy Adams" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/7aj_header_sm.jpg"
Name="Andrew Jackson" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/8mv_header_sm.jpg"
Name="Martin Van Buren" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/9wh_header_sm.jpg"
Name="William H. Harrison" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/10jt_header_sm.jpg"
Name="John Tyler" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/11jp_header.jpg"
Name="James K. Polk" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/12zt_header_sm.jpg"
Name="Zachary Taylor" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/13mf_header_sm.jpg"
Name="Millard Fillmore" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/14fp_header_sm.jpg"
Name="Franklin Pierce" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/15jp_header_sm.jpg"
Name="James Buchanan" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/16al_header_sm.jpg"
Name="Abraham Lincoln" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/17aj_header_sm.jpg"
Name="Andrew Johnson" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/18ug_header_sm.jpg"
Name="Ulysses S. Grant" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/19rb_header_sm.jpg"
Name="Rutherford B. Hayes" />
<local:ImageURL
ImageURI="http://www.whitehouse.gov/assets/presidents/20jg_header_sm.jpg"
Name="James Garfield" />
</local:Images>

Harold Bamford  Sep 15, 2009 
PDF Page 437
Example 19-1 code

There are two typos.

First, FileCopier's namespace should be "Windows_Forms_File_Copier" with this chapter's description (P420).

Second, calling FillDirectoryTree parameter should be "tvwDestination".
There is no control named "tvwTarget" (Table 19-1).

Yukitoshi Suzuki  Dec 14, 2008 
PDF Page 456
not applicable

Missing section on 'Creating type at runtime' (reflection emit) which is suggested to be after the section on Late Binding. The chapter ends all of a sudden moving on to the Chapter about Threading and Synchronization.

Anonymous  Jul 04, 2008 
Printed Page 471
multiple

Example 21-2 makes at least a few mentions of there being 3 threads, but the actual example code has 4 threads. The last mention of 3 threads is on the last line of the "Killing Threads" section on page 474.

Anonymous  Aug 29, 2011 
Printed Page 525
the example code

In example 22-12 should implement the server, but the printed example contains the client code. The text states that, "... with the client following later in Example 22-13". Example 22-13, though, is about web streams. The complete server code, in fact, is not to be found anywhere in the chapter.

Anonymous   
Printed Page 525
example 22-12

Date: Wed, 02 Jul 2008 19:29:57 +0200
From: Jan Wibom <08.364207@telia.com>
To: booktech@oreilly.com
Subject: Concerning "Programming C# 3.0" by Jesse Liberty

Hi,

I am currently translating the above mentioned book to swedish for the
swedish edition of it, published by Pagina Forlags AB. While translating
chapter 22 I have found that some errors. At page 525, the example code
in example 22-12 should implement the server, but the printed example
contains the client code. The text states that, "... with the client
following later in Example 22-13". Example 22-13, though, is about web
streams. The complete server code, in fact, is not to be found anywhere
in the chapter.

I just wanted to turn your attention to this problem, if you&#65533;d want
correct the error for future editions.

Yours sincerely,

Jan Wibom

Anonymous  Jul 02, 2008 
Printed Page 525
example 22-12

I just want to add yet another voice to say that Example 22-12 is a client source instantiation, and that the server source is completely missing.

LionKimbro1  Jul 30, 2009 
Printed Page 548
Adding Control to the Form

When attempting to add ActiveX control AxCalcControl.dll I get an error dialog:
---------------------------
Microsoft Visual Studio
---------------------------
There are no components in 'D:\Downloads\AxCalcControl.dll' that can be placed on the toolbox.
---------------------------
OK
---------------------------

I've used AxImp, with Administrator rights, to recreate the DLLs but with the same result. I can use the control successfully with VB6.

Viz Studio 2008 SP1
Windows 7 Pro x64

PodHunter  Dec 14, 2009 
Printed Page 567
Bottom of page

Missing entry for the 'var' (anonymous type) keyword in the C# Keywords section, as well as in the index.

Anonymous   
Printed Page 567
Bottom of page

Missing entry for the 'var' (anonymous type) keyword in the C# Keywords section, as well as in the index.
Cheers,
David

Anonymous  Jun 06, 2008 
Printed Page 649
Example 15-2 Line 18

The code listing reads:
Customer donna = dc.Customers.Single(c => c.FirstName == "Donna");");

It appears that the last three characters of the line -- "); -- were repeated as they do not make any sense in the syntax of the code.

Anonymous  Jun 26, 2008