- You have two objects that came from different places, and need to know if they represent essentially the same data.
- You can't override Equals unless you also override GetHashCode. If two objects are equal, they must have the same hashcode, or collections are screwed.
- GetHashCode must return the same value for an instance throughout it's lifetime, or Hashtable's are screwed
- Your object isn't readonly, so you need an immutable field in the instance to base the hashcode on.
- But if you modify one instance's data to equal another, that field can't change, so the hashcodes are still different.
- You're screwed
More reading:
UPDATE 10/04/08: Some clarifications: I'm talking about not overriding Equals/GetHashCode for reference types here. It's not such a problem for value types [as IDisposable points out in the comments]. And I've futher clarified some of my assertions about GetHashTable in the comments.
[1] PS: Like all advice, this has exceptions. But the chances are they don't apply in your case. No, really.