Errata

Programming Microsoft® Visual C#® 2008: The Language

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

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
Printed Page 23
1st paragraph

Error states that, "In addition, the variable [of a foreach loop] is read-only. Even using the variable in a context that implies change, such as passing the variable as a ref function parameter, is an error."

I iterate through collections and edit their members all of the time.

J. cody Stockwell  Jul 29, 2013 
Printed Page 118
first paragraph


Abstract classes can also contain abstract members that are defined with protected or internal accessibility. On the previous page the book mentions "Members of an interface are implicitly both public and abstract" but this is misleading. Members of an interface can ONLY be public, and are understood to be public if no accessibility modifier is present.

In abstract classes, abstract members are not implicitly public (in a class, even an absract one, members are implictly private) so not only is it necessary in abstract classes to explicitly include the modifier, you have more freedom in an abstract class to define protected, internal, or protected internal abstract methods. Of course, an abstract method can never be private.

In this list of differences between interfaces and abstract classes it is not mentioned that abstract classes can contain static and private (non-abstract) members, which is an additional useful distinction between the two.

Ben Wilson  Jul 22, 2010 
Printed Page 118
last paragraph

Book states "baselist is a list of zero or more interfaces from which the derived interface inherits".

This should be "... one or more interfaces..." - compiler will refuse a colon followed by zero types.

Ben Wilson  Jul 23, 2010 
Printed Page 211
Table 5-2

Method "Exists<T>" is incorrectly spelled as "Exist<T>" in the column "Syntax"

Ben Wilson  Jul 22, 2010 
Printed Page 211
Table 5-2

The syntax for the method ConvertAll does not fit with official documentation:

Book says:

static <destinationType> ConvertAll<sourceType, destinationType>{
sourceType sourceArray,
Converter<sourceType, destinationType> converter
)

should be as per msdn:

public static TOutput[] ConvertAll<TInput, TOutput>(
TInput[] array,
Converter<TInput, TOutput> converter
)

Ben Wilson  Jul 22, 2010 
Printed Page 220
bottom

In the section "Comparable Elements" five methods from System.Array are listed: IndexOf, LastIndexOf, Sort, Reverse, and BinarySearch. In the first paragraph of page 221 it is stated that the elements of the arrays processed by these methods must be instances of comparable types, and implement the IComparable interface.

This is not correct - only two of the methods (BinarySearch and Sort) base their functionality on an implementation of IComparable.CompareTo. The other three (IndexOf, LastIndexOf, and Reverse) do not use or require this at all and use different mechanisms instead.

Ben Wilson  Jul 22, 2010 
Printed Page 224
Table 5-4

Table 5-4 provides details on the implementation by System.Array of IList members. The table lists methods Clear and IndexOf as "public" and the rest as "private" however the msdn documentation lists each one as private and none as public.

Add, Insert, Remove, and RemoveAt should be private; Clear and IndexOf are available (though not necessarily "public") through an explicit interface implementation, and Contains is available to object references of Array type directly through a method extension.

Ben Wilson  Jul 22, 2010 
Printed Page 233
row "LastIndexOf"

Syntax example #1 is "virtual int LastIndex(object value)" and should be "virtual int LastIndexOf(object value)"

Ben Wilson  Jul 26, 2010 
Printed Page 284
top

The lower boundary checks on the row and col parameters are incorrect and allow the indexer code on the previous page to break with a negative array index -

is:

public void ValidateCell(byte row, byte col) {
if ((row < 0) || (row > m_Dimension)) {
throw new Exception("Invalid Row");
}
if ((col < 0) || (col > m_Dimension)) {
throw new Exception("Invalid Col");
}
}

should be:

public void ValidateCell(byte row, byte col) {
if ((row < 1) || (row > m_Dimension)) {
throw new Exception("Invalid Row");
}
if ((col < 1) || (col > m_Dimension)) {
throw new Exception("Invalid Col");
}
}

and could be simplified to:

public void ValidateCell(byte row, byte col) {
if (row < 1 || row > m_Dimension) {
throw new Exception("Invalid Row");
}
if (col < 1 || col > m_Dimension) {
throw new Exception("Invalid Col");
}
}

Ben Wilson  Jul 26, 2010 
Printed Page 287
top

Two mistakes in the generic type syntax:

1) <classname> should be followed by a <parameterlist>, just like <baselist> is
2) no colon follows <constraintlist>

Ben Wilson  Jul 27, 2010 
Printed Page 302
table 7-1

In Table 7-1 it is mentioned that for a base class Generic (open) it is "permitted" to inherit whereby a derived class is non-generic.

In the examples a few lines down however this is contradicted:

public class YClass : ZClass<T> { // illegal
}

Ben Wilson  Jul 21, 2010