>From my understanding of Richter's book (Applied MS .NET Framework
Programming) implementing Equals for a type is tricky.

The issue is that System.Object.Equals is implemented essentially as
ReferenceEquals.  If you derive from a class, and override Equals you have
to take great care deciding on when to chain down to the base class
implementation.  If the base class doesn't override the method you will end
up with ReferenceEquals, which is probably not what you wanted or you
wouldn't be overriding Equals in the first place.  However, if the base
class does then you must chain down.

I'm relatively new to this - well, I'm coming back to it after a long
break - so I'm wondering how people handle this.  How can I tell if the
class I am inheriting from has provided an override for Equals - or any
classes it inherits from?  Is it a matter of documentation?  Or is there any
other way to tell?  I'm thinking about the case when I didn't write the base
class for example.

Thanks!

-John

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