ValueType.Equals Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Indicates whether this instance and a specified object are equal.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- obj
- Type: System.Object
Another object to compare to.
Return Value
Type: System.Booleantrue if obj and this instance are the same type and represent the same value; otherwise, false.
The following example demonstrates how the Equals method can be overridden by a derived value type.
public struct Complex { public double m_Re; public double m_Im; public override bool Equals(object ob) { if (ob is Complex) { Complex c = (Complex)ob; return m_Re == c.m_Re && m_Im == c.m_Im; } else { return false; } } public override int GetHashCode() { return m_Re.GetHashCode() ^ m_Im.GetHashCode(); } }
Show: