cover image

Chapter 4 Introduction, p. 179

“crated a roundtable” should be “created a roundtable”

Created on 5/24/2010 2:02:00 PM

Filed in: 2nd edition,


Item 29, p. 176

In the second to last sentence, “an delegate” should be “a delegate”.

Created on 5/24/2010 2:01:39 PM

Filed in: 2nd edition,


Item 23, p. 139-140

There are a couple code samples that do not correctly reflect the text.  First, the sample on the bottom of p. 139 must include the ‘new’ keyword on the Message() method:

 public class MyDerivedClass : MyClass
{
public new void Message()
{
Console.WriteLine("MyDerivedClass");
}
}

 

Secondly, the declaration of MyDerivedClass on p.140 should include the IMsg interface:

 public class MyDerivedClass : MyClass, IMsg
{
public new void Message()
{
Console.WriteLine("MyDerivedClass");
}
}

Created on 5/24/2010 2:01:14 PM

Filed in: 2nd edition,


Item 16, p. 95

The last sentence in the 2nd to last paragraph references the wrong item number.  It reads “Item 18 explains how to do just that [Implement the Dispose pattern].”  It should read “Item 17 …”.

Created on 5/24/2010 2:00:37 PM

Filed in: 2nd edition,


Item 9, p.59-60.

This snippet span the bottom of p. 59 and the top of p. 60:

 

 Circle c = new Circle(new PointF(3.0f, 0), 5.0f);
Flatten(c);
// Work with the circle.
// ...

// Convert to an ellipse.
Ellipse e = new Ellipse(c);
Flatten(e);

 

It should read:

 Circle c = new Circle(new PointF(3.0f, 0), 5.0f);

// Work with the circle.
// ...

// Convert to an ellipse.
Ellipse e = new Ellipse(c);
Flatten(e);

Created on 5/24/2010 1:58:55 PM

Filed in: 2nd edition,


Item 3, p. 17-18

The sample that starts at the bottom of p. 17 and continues to the top of p. 18 should read as follows:

 object o = Factory.GetObject();

MyType t = null;
if (o as MyType != null)
t = o as MyType;

The sample in the first printing is repeated from the previous sample.

Created on 5/24/2010 1:57:57 PM

Filed in: 2nd edition,


Item 3, p. 13: Update to Sample

The second sample does not show the null check described in the text.  It should read as follows:

 

 try
{
MyType t;
t = (MyType)o; // Fails. o is not MyType
if (t != null)
{
// work with T, it's a MyType.
}
}
catch (InvalidCastException)
{
// report the conversion failure.
}

Created on 5/24/2010 1:56:28 PM

Filed in: 2nd edition,


Variable typo on p. 119

This code snippet:

// remaining details elided
public string Line1
{
    get { return Line1; }
}
private readonly string line1;

Should be:

// remaining details elided
public string Line1
{
    get { return line1; }
}
private readonly string line1;

Sadly, the code as shown in the book, will have an infinite loop.

Created on 3/20/2010 9:05:50 PM

Filed in: 2nd edition,


Errata below represent the first edition

The second edition of Effective C# is almost out. That means it's time for a little maintenance to the errata page.

All items older than this marker are part of the first edition. Also, you can use this tag to see only the errata from the first edition: http://srtsolutions.com/blogs/effectivecsharp/archive/tags/1st+edition/default.aspx

All items news than this item are in the second edition. Or, you can use this tag to see only errata from the second edition: http://srtsolutions.com/blogs/effectivecsharp/archive/tags/2nd+edition/default.aspx

 

Created on 1/31/2010 8:45:00 PM

Filed in: 1st edition, 2nd edition,


error in Item 5, p. 37

Missing format string

On page 37, in item 5, the line of code that reads:

    Console.WriteLine( string.Format( new CustomerFormatter(), "", c1 );

should read:

    Console.WriteLine( string.Format( new CustomerFormatter(), "{0}", c1 );



Created on 7/25/2007 4:37:45 PM

Filed in: Item 5, 1st edition,


P 19, (item 3)

missing char

The code at the bottom of p. 19 reads:

//Version two

try
{
   MyType t1;
  
t = (MyType)o;

It should be:

try
{
   MyType t1;
  
t1 = (MyType)o;



Created on 7/16/2006 8:47:03 PM

Filed in: Item 3, 1st edition,


p. 122 (Item 19)

Wrong word in 3rd paragraph

The second sentence in the third paragraph reads:    "It [IListSource] also has a containsListCollection property so that  users can modify the overall structure of the collection."

It should read:  "It [IListSource] also has a containtsListCollection property so that users can navigate the overall structure of the collection."

(Bold indicates the change, not emphasis). 



Created on 7/7/2006 11:21:44 PM

Filed in: Item 19, 1st edition,


Poor word choice in Item 3

You could easily mis-interpret what I said about the as and is operators

At the bottom of page 18, in Item 3, I wrote this sentence:

"If a particular object is not the requested type or is derived from the requested type, they fail."

A better choice would have been:

"If a particular object is not the requested type, nor a type derived from the requested type, they fail."




Created on 1/9/2006 5:58:39 PM

Filed in: Item 3, 1st edition,


Errata: Item 10

p. 63.

Item 10 incorrectly implies that System.ValueType contains a static operator ==.

It doesn't. 

However, many developers do create what seems like a simple solution:

struct MyType
{
  // data members elided.
  static bool operator == ( MyType l, MyType r )
  {
    return l.Equals ( r );
  }
  // Note no override of Equals.  
}

That will cause the behavior I mentioned in the item. The reason is that ValueType.Equals() does use reflection to find the values of each field in the objects being compared.



Created on 11/15/2005 8:54:48 AM

Filed in: Item 10, 1st edition,


Clarification: Item 22

Elided code was not clearly marked
Both listener classes on p. 134 should include a private declaration of the Logger Singleton class:


        private static Logger logger;


This declaration was removed from the code listing, but not discussed in the text.

 

 

Created on 8/29/2005 6:22:00 PM

Filed in: Item 22, 1st edition,