This documentation is archived and is not being maintained.
ValueType::Equals Method
Visual Studio 2010
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 ref struct Complex { public: double m_Re; double m_Im; virtual bool Equals( Object^ ob ) override { if ( dynamic_cast<Complex^>(ob) ) { Complex^ c = dynamic_cast<Complex^>(ob); return m_Re == c->m_Re && m_Im == c->m_Im; } else { return false; } } virtual int GetHashCode() override { return m_Re.GetHashCode() ^ m_Im.GetHashCode(); } };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: