Programming C#

Errata for Programming C#

Submit your own errata for this product.

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

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

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

Version Location Description Submitted By Date Submitted Date Corrected
Page 69
end of 4th paragraph

"[...], strings to the empty string, etc.)." should be: "[...], strings to null, etc.)." Page 70 The DateTime structure is a value type (not a reference type) and is passed by value to the Time constructor. Page 73 Copy Constructors - this discussion should include a discussion of the ICloneable Interface, defined by the Framework. ICloneable defines a single method: Clone(). Classes that support cloning should implement ICloneable, and then should implement either a shallow copy (calling MemberwiseClone) or a deep copy (by calling the copy constructor or by hand copying all the members). class SomeType : ICloneable { public Object Clone() { return MemberwiseClone(); // shallow copy } } Page 97 Figure 5-3 is a duplicate of 5-2. Instead it should look more like this: (Fig 5-3 is here - ) Page 111 Example 5-4 Change member variable value to val throughout (value is a keyword) Page 123 second paragraph. [12/4/02] Currently: "Thus, if the fraction is 15/16, the resulting integer value will be 1" Should be: "Thus, if the fraction is 15/16, the resulting integer value will be 0" Page 127 Ex. 7-1 myFunc method [12/4/02] Currently: Console.WriteLine("Loc1 location: {0}", loc); Should be: Console.WriteLine("In MyFunc. loc: : {0}", loc);

Page 142
4th paragraph

the line - isDoc.status = 0; should read isDoc.Status = 0; Page 149 Example 8-4 Currently: IStorable isNote2 = note2 as IStorable; if (isNote != null) Should be: IStorable isNote2 = note2 as IStorable; if (isNote2 != null) Page 154 Selectively Exposing Interface Methods Currently: Talk.Read Should be: ITalk.Read

Page 158
IN PRINT: Last and third to last paragraphs

When explaining the code in example 8-6 the theStruct.Status property is sometimes referred to as theStruct.status which is not a property but a private member of the myStruct class. This is probably a case typo mistake. AUTHOR: Correct. Page 224 The assignment operator does not make a copy of the string, it makes a copy of the reference. If, however, you modify the string, then the references are separated. Page 266 4th paragraph. Please remove the qualifying word static in the description of which methods the delegate can encapsulate. Page 277 Ex. 12-2 The example in the book uses static methods which could not impact an instance of Image. The new source code modifies this example to use instance methods. Please download source code version 16 or later Page 280 Just before Example 12-3 [1/9/03] Currently: DelegateCollector -= Logger Should be: myMulticastDelegate -= Logger

Page 283
first paragraph under Events

...and web browsers (such as Microsoft) should be ...and web browsers (such as Microsoft Internet Explorer) Page 331 Listing 13-3 is truncated. Please add these lines... [7/15/02] fileList.Sort(comparer); return fileList; } } } Page 353 Second paragraph change ADODataAdapter to OLEDBDataAdapter Page 388 Figure 15-1 is a bit out of date, and will be updated in the next edition Page 390 Second paragraph. Change HelloWeb.cs to HelloWeb.aspx.cs Page 391 Figure 15-2 should show the current date and time. Page 429 Currently says that when loading the assembly the resolver will probe the current directory and its subdirectories. This has changed. The Assembly Loader now checks the application base, the culture and name of the referenced assembly and then a private binpath, which is a user-defined list of subdirectories under the root location. For a sample, see GotDotNet Page 510 middle of the page [1/9/03] Currently: // tell thread 1 to abort Should be: // tell thread 2 to abort Page 516 - Please modify the Interlocked.Increment example to use a temporary variable, as shown here: while (counter < 1000) { int temp = Interlocked.Increment(ref counter); Thread.Sleep(1); Console.WriteLine("Thread {0}. Incrementer: {1}", Thread.CurrentThread.Name, temp); Page 518 Please modify the lock example to display the temporary variable, as shown here: while (counter < 1000) { int temp; lock (this) { temp = counter; temp++; Thread.Sleep(1); counter = temp; } Console.WriteLine("Thread {0}. Incrementer: {1}",Thread.CurrentThread.Name, temp); } Exercise 21-7 - I've updated the source code to use FileStream to explicitly open the file in asynch. mode. Please download the updated source code. Page 574 Example 21-15 In the method DeSerialize, the code closing the FileStream is unreachable (causes a warning). Please replace with: public static SumOf DeSerialize() { FileStream fileStream = new FileStream("DoSum.out",FileMode.Open); BinaryFormatter binaryFormatter = new BinaryFormatter(); SumOf retVal = (SumOf) binaryFormatter.Deserialize(fileStream); fileStream.Close(); return retVal; } page 587 Figure 22-5 Figure 22-5 is incorrect, it's the same one as 22-4. Page 609 Second glossary item should be as