Why were Equals () and == different?

This question is not about the differences between == and Equals . This is about why they were different.

We know that the differences cause a lot of problems that must have been pretty easy to spot:

  • Equals and == give different results for two instances of the same object.
  • == give different results when comparing subclasses, since == not polymorphic
+7
c #
source share
1 answer

The short answer is that the C # language development team and the .NET Framework development team could not agree on how best to compare values ​​/ objects for equality, so each of them implemented its own system.

For a more technical answer, see Eric Lippert's blog post on this subject .

+3
source share

All Articles