Is there a complete IEquatable implementation reference?

Viewed 23723

Many of my questions here on SO concerns IEquatable implementation. I found it being extremely difficult to implement correctly, because there are many hidden bugs in the naïve implementation, and the articles I found about it are quite incomplete. I want to find or write a definitive reference which must include:

  • How to implement IEquatable correctly
  • How to override Equals correctly
  • How to override GetHashCode correctly
  • How to implement the ToString method correctly
  • How to implement the operator == correctly
  • How to implement the operator != correctly

Such a complete reference already exists?

PS: Even MSDN reference seems flawed to me

5 Answers
Related