Check out the errata page at www.wintellect.com - I think I remember that
section having an update.

-----Original Message-----
From: Yong Xu [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 17, 2002 1:22 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Implementing Equals


Hi there,
In Jeffrey Richter's recent book, Applied .NET Framework programming, Page
156, he demonstrated how to implement Equals for a reference type whose base
class overrides Object's Equals. He wrote this,
// let the base type compare its fields
if (!base.Equals(obj)) return false;
...
// If the objects are of different types, they can't be equal
if (this.GetType() != obj.GetType()) return false;
...
However, if the base class implements its Equals in the similar way, since
GetType is not virtual, then either base's (this.GetType() != obj.GetType())
or the derived class's one must evaluate to false. Hence the derived class's
Equals will always return false.
Do I miss anything?
TIA,
Yong

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to