O'Reilly logo
  • Ismael Lanchas thinks this is interesting:

When Equals and == are not equal

We said earlier that it’s sometimes useful for == and Equals to apply different definitions of equality. For example:

double x = double.NaN;
Console.WriteLine (x == x);            // False
Console.WriteLine (x.Equals (x));      // True

The double type’s == operator enforces that one NaN can never equal anything else—even another NaN. This is most natural from a mathematical perspective, and it reflects the underlying CPU beha...


Cover of C# 6.0 in a Nutshell, 6th Edition


Es importante sobrescribir Equals para cuando se debe usar por parte de colecciones o diccionarios.