C# in a Nutshell By Peter Drayton, Ben Albahari The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification This page was updated June 22, 2004. UNCONFIRMED errors and comments from readers: (3) 3rd paragraph; "However, in addiction to its technical merits" should be "However, in addition to its technical merits". {15} top, in list of Identifiers and Keywords; "value" should be included as a keyword. [21] 1st code paragraph, comment block for b = new PointV;; Statement: "Calls the value types defaut contstructor" is false. C# does not automatically call default paramaterless constructors for value types, nor does it even let them be defined. [23] List at bottom; "- Floating-point (float, decimal, char, bool)" Firstly, this misses out double as a floating-point type. Secondly, it lists char and bool as floating-point types which they most certainly aren't. {24} Under "integral types"; "possible values range from 0 to 2" should be "possible values range from 0 to (2^n)- 1" {25} 1st paragraph; The text reads "For unsigned integers that are n bits wide, possible values range from 0 to 2^(n-1)." when it should be (2^n)-1 (30) 2nd paragraph; sentence reads "ensures that a variable can be operated on through only via the correct type with the help of runtime checking" I believe a more readable version of this should be "ensures that a variable can be operated on only via the correct type with the help of runtime checking" (33) Under "operator precendence"; "C# overloads operators, which means the same operator, or has different meanings for different types."... not sure what, exactly, this was meant to say. (33) 5th paragraph; "* has a higher precedence that +" should read "* has a higher precedence than +". (34) middle; "Less than: <<" should be "Less than: <". (34) Operators list; The following operators should be in italics, indicating that they may be overloaded (only those that are erroneously printed are listed below): Relational operators: Greater than: > Less than or equal to: <= Greater than or equal to: >= Equality: Not equals: != Logical bitwise: And: & Exclusive or: ^ Or: | (37) middle; "It is very common to use the || and && and ! operators to test for AND, OR, and NOT conditions" should be "It is very common to use the && and || and ! operators to test for AND, OR, and NOT conditions {44} final paragraph on page; Text reads "In this example, the class Example is declared in the global namespace," Howver,there is no class Example. There is a class Test however. Thus, I believe that the sentence should read "In this example, the class Test is declared in the global namespace," (51) Overloading Methods Example; viod Foo(double x); should be void Foo(double x); (52) 1st paragraph under "Instance Constructors"; The sentence reads "Constructors allow initialization code to perform for a class or struct." It should probably read something like "Constructors allow initialization code to perform setup/initialization tasks for a class or struct". {57} Last class example (Location); The intent of the overridden Display() function is to chop off the "http://" portion of a string, but the code says to write out Name.Substring(6) - which would start at the second "/" of "http://". I think the author meant to say "Name.Substring(7)". (57) last paragraph; "The Show method in the Example class in the previous section" should be "The Show method in the Test class in the previous section" {60} 3rd class example (Hermit); The sentence right above the Hermit class reads "The following builds upon our example using the this keyword:" and the class following that sentence reads like this: class Hermit : Dude { public void new Introduce(Dude a) { base.TalkTo(a); Console.WriteLine("Nice Talking To You"); } } But when looking back at the example with the this keyword on page 47, the Dude class does not have a member called TalkTo. There is however a member called Introduce with the same signature as what the TalkTo should have so I guess our Hermit class here should read like this: class Hermit : Dude { public void new Introduce(Dude a) { base.Introduce(a); // call Dude's Introduce Console.WriteLine("Nice Talking To You"); } } (60) 1st paragraph after "The base Keyword"; The final sentence reads "The following builds upon our example using the this keyword", which could be taken to mean that the following example uses the this keyword. Perhaps a clearer wording would be something like "The following builds upon the Dude class that we used in the section describing the this keyword". (66) 2nd code part; "interface IDesigntimeControl {...}" should read "interface IDesignTimeControl {...}". (71) 2nd title; "Declaring and Firing and Event" should be "Declaring and Firing an Event" (76) second paragraph; reads: "A try block must be followed by a catch block(s), a finally block, or both." This could be expressed more clearly as: "A try block must be followed by a catch block(s), and/or a finally block." I know from 11th grade English that the "and/or" construct is not viewed favorably, however, I think in this case it makes the intent clearer. Further, you might point out explicitly that a catch or finally block is not allowed unless immediately preceded by a try block. {76} last line; "if metersTall < 0 || weightKilos > 1000)" should logically be "if weightKilos < 0 || weightKilos > 1000)" [100] Graphics Subsection; The quick reference section does not contain the System.Graphics namespace at all. It is described on page 100 but no where in the book itself. [115 - 116} It seems the regex cookbook entries don't pass the propert type of value for RegexOptions. The "Deleting C comments" example (top of p115) and the "Finding simple links in HTML" (p116) pass a string for the options, rather than proper options. Perhaps this was allowed in one of the betas, but it doesn't seem to be allowed now. (127) 2nd code example; The the 2nd return statement reads "return s1.Equals(s1);", it should probably read "return s1.Equals(s2);". (132) 3rd sample code; XmlTextWriter xw = new XmlTextWriter("greetings.xml"); should read XmlTextWriter xw = new XmlTextWriter("greetings.xml",null); or XmlTextWriter xw = new XmlTextWriter("greetings.xml",System.Text.Encoding.UTF8); xw.Formatting = Indented; should read xw.Formatting = Formatting.Indented; xw.Write(messageOfTheDay); should read xw.WriteString(messageOfTheDay); (171) 8th paragraph (Retrieving a Type Directly); There seems to be no overloaded methods of Type.GetType that match the second example call in this paragraph which is Type t2 = Type.GetType("MyNamespace.MyType, MyAssembly"); There seem to be only three overloads GetType(string typeName); GetType(string typeName, bool throwOnError) GetType(string typeName, bool throwOnError, bool ignoreCase) {190} Last paragraph ("Atomic Operations"); This paragraph contains the statement: " ... updating a variable is atomic, because the operation is guaranteed to complete without control being passed to another thread." However, (on 32-bit architectures at least) this is only true for data types of size upto and including 32-bits. Specifically, reading/writing variables with 64-bit data types or most user-defined value types is NOT guaranteed to be atomic (see section 12.5 of the C# Language Specification). {196,197} "In and Out Marshalling"; The keywords "in" and "out" need to be capitalized. So the example at the top of page 197 should read: static extern void Foo([In] int[] array); At least that's the only way it will compile for me. (212) when describing how to log a method on a preceding stack frame: Debug.WriteLine( "MethodCall", s ); // Dump methodcall should be: Debug.WriteLine( s, "MethodCall" ); // Dump methodcall (237) 2nd paragraph; The very last word of the 2nd paragraph (Table 22-2) doesn't exist. It should be (Table 22-1). {237} throughout table 22-1.; Most keywords are lower case. Such as "Return" should be "return". [407] Whole section missing; Omission of the class hierarchy for System.Data {467} Figure 31-2; Figure 31-2 has IOException extending Exception and PathTooLongException extending SystemException by itself. It should be IOException extends SystemException and PathTooLongException extends IOException. (813) 2nd Column; Indexing Error. Syntax description for "Indexers" is on page 227, not page 223.