description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||
---|---|---|---|---|---|---|---|
Compiler Warning (level 3) CS0660 |
Compiler Warning (level 3) CS0660 |
07/20/2015 |
|
|
2f77b45b-c5c6-46af-abe9-002e67887896 |
'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 xref:System.Object.Equals%2A?displayProperty=nameWithType method. A user-defined equality or inequality operator implies that you also want to override the xref:System.Object.Equals%2A method. For more information, see How to define value equality for a type.
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()
{
}
}