Compiler Warning (level 3) CS0660
'class' defines operator == or operator != but does not override Object.Equals(object o)
The compiler detected the user-defined equality or inequality operator, but no override for the Equals function. A user-defined equality or inequality operator implies that you also want to override the Equals function. For more information, see Equality Comparisons (C# Programming Guide).
The following sample generates CS0660:
// CS0660.cs
// compile with: /W:3 /warnaserror
class Test // CS0660
{
public static bool operator == (object o, Test t)
{
return true;
}
// uncomment the Equals function to resolve
// public override bool Equals(object o)
// {
// return true;
// }
public override int GetHashCode()
{
return 0;
}
public static void Main()
{
}
}
Change History
Date |
History |
Reason |
---|---|---|
September 2008 |
Added link to related topic. |
Customer feedback. |