Programming Microsoft® Visual C#® 2005: The Language

Errata for Programming Microsoft® Visual C#® 2005: The Language




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
Page CD-ROM

Updated code samples for Refactoring Walkthrough in chapter 4 available for download Updated code samples are available for the Refactoring Walkthrough in chapter 4. The following file is available for download from the Microsoft Download Center: Airline.exe (http://download.microsoft.com/download/3/1/a/31aab2cf-c7b0-437d-ae52-ab34d3a79f8b/airline.exe)

Microsoft Press  Jul 13, 2010 
Other Digital Version
CD-ROM

Incorrect variable name used in Chapter 2prop_errorperson1.cs and Chapter 2prop_errorperson2.cs sample files The ninth line of both the Chapter 2prop_errorperson1.cs and Chapter 2prop_errorperson2.cs sample files reads: if(age120) {It should read: if(value120) {

Microsoft Press  May 06, 2010 
Printed
Page 11

Missing ")" and ";" in code sample On Page 11, the 12th line of the first code sample reads: Console.WriteLine(objGreeting.FrenchIt should read: Console.WriteLine(objGreeting.French);

Microsoft Press  May 06, 2010 
Printed
Page 15

Error should be Pragma On page 15, midway down the page, it reads: "The #pragma directive enables or disables standard compilation warnings. Error directives: #error warning disable warning_list #error warning restore warning_list "It should read: "Pragma directives: #pragma warning disable warning_list #pragma warning restore warning_list "

Microsoft Press  Jul 13, 2010 
Printed
Page 21

Incorrect Sample code for Postfix Increment and Postfix Decrement in Table 1-4 On page 21, the Postfix Increment and Postfix Decrement rows of Table 1-4 read: Postfix Increment ++ variable --; 10; 10 Postfix Decrement -- variable ++; 11They should read: Postfix Increment ++ variable ++; 11 Postfix Decrement -- variable --; 10

Microsoft Press  May 06, 2010 
Printed
Page 24

Error in Conditional Operator example On page 24, under Ternary operators, the Conditional Operator example currently reads: boolean_expression:truth_statement?false_statementIt should read: boolean_expression?truth_statement:false_statement

Microsoft Press  Jul 13, 2010 
Printed
Page 33

Multiple errors in Figure 1-3 On page 33, Figure 1-3 contains mlutiple errors in both columns. Under file1.cs change: "NamespaceA" To: "NamespaceZ" Also under file1.cs completely remove the reference to "namespace NamespaceB". Under file2.cs change: "namespace NamespaceA namespace Namespace C" To: "namespace NamespaceZ namespace NamespaceY"

Microsoft Press  May 06, 2010 
Printed
Page 37

Variable name error in code sample On page 37, the second code sample in the "Nullable Types" section reads: double? variablea=null;It should read: double? variable1=null;

Microsoft Press  Jul 13, 2010 
Printed
Page 37

variablea referenced in place of variable2 On page 37, the second to last sentence of the final paragraph reads: "This code sets the default value for variablea to zero." It should read: "This code sets the default value for variable2 to zero."

Microsoft Press  May 06, 2010 
Printed
Page 40

Error in switch statement explanation On page 40, below the sample Switch statement code, the sixth sentence in the paragraph reads:"If switch label matches the switch expresssion..."It should read: "If no switch label matches the switch expression..."

Microsoft Press  Jul 13, 2010 
Printed
Page 48

Incorrect variable name used in code sample On page 48, the ninth and tenth lines of the code sample read: Employee Jim=new Employee(); Fred.name="Wilson, Jim";They should read: Employee Fred=new Employee(); Fred.name="Wilson, Fred";

Microsoft Press  May 06, 2010 
Printed
Page 54

Reference to Chapter 9 is incorrect On page 54, the 4th sentence under the Volatile Fields heading contains incorrect information regardinds Locks. Change: "Locks are explained in Chapter 9, “Threading.”" To: "Locks are explained in Chapter 13, “Threads.”"

Microsoft Press  Jul 13, 2010 
Printed
Page 54

Incorrect reference to Chapter 6 On page 54, the last sentence under the Member Functions paragraph contains an incorrect reference to Chapter 6. Change: "The discussion of indexers is deferred to Chapter 6, “Arrays and Collections.”" To: "The discussion of indexers is deferred to Chapter 5, “Arrays and Collections.”"

Microsoft Press  May 06, 2010 
Printed
Page 58

"Chapter 6" should be "Chapter 5" On page 58, the 3rd sentence of the "Function parameters" paragraph contains an incorrect reference to Chapter 6. Change: "Use the param keyword to construct a variable length parameter list, which is discussed in Chapter 6." To: "Use the param keyword to construct a variable length parameter list, which is discussed in Chapter 5."

Microsoft Press  Jul 13, 2010 
Printed
Page 66

Error in description of constructor output On page 66, the fourth sentence of the paragraph immediately following the bulletted list reads: "The static constructor is stubbed to output a method." It should read: "The static constructor is stubbed to output a message."

Microsoft Press  May 06, 2010 
Printed
Page 68

Destructor description missing the word "name" On page 68, the fifth sentence of the Destructors section reads: "Like a constructor, the destructor has the same as the class..." It should read: "Like a constructor, the destructor has the same name as the class... "

Microsoft Press  Jul 13, 2010 
Printed
Page 68

"Chapter 16" should be "Chapter 14" On page 68, the last sentnce of the "Destructors" paragraph and the 3rd sentence under the "Destructor syntax" contain an incorrect reference to Chapter 16. Change: "Implementing a disposable pattern is one of the topics found in Chapter 16." To: "Implementing a disposable pattern is one of the topics found in Chapter 14." Change: "These topics are also covered in Chapter 16." To: "These topics are also covered in Chapter 14."

Microsoft Press  May 06, 2010 
Printed
Page 70

Comment contains incorrect method On page 70, line 19 of the code example contains an incorrect method in comments. Change: Console.WriteLine(bob.age); // Call gets methodTo: Console.WriteLine(bob.age); // Calls get method

Microsoft Press  Jul 13, 2010 
Printed
Page 71

Term "backing" used in place of the term "data" On page 71, the first line currently reads: "public, whereas the backing store is private." This should read: "public, whereas the data store is private. "

Microsoft Press  May 06, 2010 
Printed
Page 80

Technical error in comparison of locala and localb variables On page 80, the fourth and fifth sentences of the second paragraph in the "Identity versus Equivalence" section read: "The variables locala and localb are not equivalent. They have the same values but are stored at different locations on the stack:" They should read: "The variables locala and localb are neither equivalent nor identical. They have different values and are stored at different locations on the stack:"

Microsoft Press  Jul 13, 2010 
Printed
Page 80

Example variable has the wrong type On page 80, the third line of the first code sample in the "Identity versus Equivalence" section reads: double localc=5;It should read: int localc=5;

Microsoft Press  May 06, 2010 
Printed
Page 150

Derived class referenced in place of base class On page 150, the last sentence of the first paragraph reads: "This both creates the inheritance relationship and adds the derived class to the class diagram." It should read: "This both creates the inheritance relationship and adds the base class to the class diagram."

Microsoft Press  Jul 13, 2010 
Printed
Page 150

Incorrect instruction for creating a derived class relationship On page 150, the third sentence on the page reads: "Drag the inheritance line from the base class to the derived class." It should read: "Drag the inheritance line from the derived class to the base class."

Microsoft Press  May 06, 2010 
Printed
Page 187

Term "multirectangle" used in place of "multidimensional" On page 187, the fourth sentence of the first paragraph reads: "Multirectangle arrays are rectangular and consist of rows and columns." It should read: "Multidimensional arrays are rectangular and consist of rows and columns."

Microsoft Press  Jul 13, 2010 
Printed
Page 201

Array.CreateInstance Method code example is partially incorrect On page 201, the code example contains incorrect array offsets. The correction starts on line 7. Change: Assembly executing=Assembly.GetExecutingAssembly(); Type t=executing.GetType(argv[0]); Array zArray=Array.CreateInstance( t, argv.Length-2); for(int count=2;count<argv.Length;++count) { System.Object obj=Activator.CreateInstance(t, new object[] { argv[count]}); zArray.SetValue(obj, count-2); } foreach(object item in zArray) { MethodInfo m=t.GetMethod(argv[1]); m.Invoke(item, null); }To: Assembly executing = Assembly.GetExecutingAssembly(); Type t = executing.GetType(argv[1]); Array zArray = Array.CreateInstance( t, argv.Length - 3); for (int count = 3; count < argv.Length; ++count) { System.Object obj = Activator.CreateInstance(t, new object[] { argv[count]}); zArray.SetValue(obj, count - 3); } foreach (object item in zArray) { MethodInfo m = t.GetMethod(argv[2]); m.Invoke(item, null); }

Microsoft Press  May 06, 2010 
Printed
Page 206

IComparer should be IComparable On page 206, the 15th line down in the second code example on the page uses an incorrect interface. Change: public class XClass: IComparer {To: public class XClass: IComparable {

Microsoft Press  Jul 13, 2010 
Printed
Page 235-236

Technical errors in code sample On pages 235-236, the code sample reads: using System; namespace Donis.CSharpBook{ public class Starter{ public static void Main(){ StackInt stack=new StackInt(5); stack.Push(10); stack.Push(15); Console.WriteLine("Pushed 3 values"); stack.ListItems(); stack.Pop(); Console.WriteLine("Popped 1 value"); stack.ListItems(); } } public class StackInt { public StackInt(int firstItem) { list=new int[1] {firstItem}; } public int Pop() { if(top!=0) { return list[--top]; } throw new Exception("Stack empty"); } public void Push(int topitem) { ++top; if(top==list.Length) { int [] temp=new int[top+1]; Array.Copy(list, temp, top); list=temp ; } list[top]=topitem; } public void ListItems () { for(int item=0;item<=top;++item) { Console.WriteLine(list[item]); } } private int [] list; private int top=0; } }It should read: using System; namespace Donis.CSharpBook{ public class Starter{ public static void Main(){ StackInt stack=new StackInt(5); stack.Push(10); stack.Push(15); Console.WriteLine("Pushed 3 values"); stack.ListItems(); stack.Pop(); Console.WriteLine("Popped 1 value"); stack.ListItems(); } } public class StackInt { public StackInt(int firstItem) { list=new int[1] {firstItem}; top++; } public int Pop() { if(top!=(-1)) { return list[top--]; //was list[--top] } throw new Exception("Stack empty"); } public void Push(int topitem) { ++top; if(top==list.Length) { int [] temp=new int[top+1]; Array.Copy(list, temp, top); list=temp ; } list[top]=topitem; } public void ListItems () { for(int item=0;item<=top;++item) { Console.WriteLine(list[item]); } } private int [] list; private int top=(-1); } }

Microsoft Press  May 06, 2010 
Printed
Page 281

The term "an enumerator" is used in place of "enumerated" On page 281, the fourth sentence of the first paragraph reads: "In Main, the collection is an enumerator in a generic and nongeneric manner." It should read: "In Main, the collection is enumerated in a generic and nongeneric manner."

Microsoft Press  Jul 13, 2010 
Printed
Page 281

Incorrect variable name used in the code sample On page 281, the 14th line of the code sample reads: foreach(int number in generic) {It should read: foreach(int number in simple) {

Microsoft Press  May 06, 2010 
Printed
Page 386-387

Incorrect code sample included On pages 386-387, the sample code in the GetGenericArguments section reads: using System; namespace Donis.CSharpBook { class ZClass { public void FunctionA(K argk, V argv) { } } class Starter { public static void Main() { ZClass obj=new ZClass(); ZClass obj2=new ZClass(); Type closedType=obj.GetType(); Type openType=closedType.GetGenericTypeDefinition(); Type closedType2=obj2.GetType(); Type openType2=closedType2.GetGenericTypeDefinition(); Console.WriteLine(openType.ToString()); Console.WriteLine(openType2.ToString()); } } }It should read: using System; using System.Reflection; namespace Donis.CSharpBook{ public class ZClass { public void MethodA(){ } public K membera; public V memberb; } class Starter{ static void Main(){ Type openType=typeof(ZClass); foreach(Type parameter in openType.GetGenericArguments()) { Console.WriteLine(parameter.ToString()); } Type closedType=typeof(ZClass); foreach(Type parameter in closedType.GetGenericArguments()) { Console.WriteLine(parameter.ToString()); } MethodInfo method=openType.GetMethod("MethodA"); foreach(Type parameter in method.GetGenericArguments()) { Console.WriteLine(parameter.Name); } } } } Microsoft Press is committed to providing informative and accurate books. All comments and corrections listed above are ready for inclusion in future printings of this book. If you have a later printing of this book, it may already contain most or all of the above corrections.The print number of the book is located on the copyright page in the form of a string of numbers. For example: "2 3 4 5 6 7 8 0 QWT 9 8 76 5 4". The first number in the string is the the print number. In this example, the print number is 2.

Microsoft Press  Jul 13, 2010