Type.Equals Method (Object)
Determines if the underlying system type of the current Type is the same as the underlying system type of the specified Object.
[Visual Basic] Overrides Overloads Public Function Equals( _ ByVal o As Object _ ) As Boolean [C#] public override bool Equals( object o ); [C++] public: bool Equals( Object* o ); [JScript] public override function Equals( o : Object ) : Boolean;
Parameters
- o
- The Object whose underlying system type is to be compared with the underlying system type of the current Type.
Return Value
true if the underlying system type of o is the same as the underlying system type of the current Type; otherwise, false. This method also returns false if the object specified by the o parameter is not a Type.
Remarks
This method overrides Object.Equals.
Example
The following example uses Equals to compare two Object instances.
[Visual Basic] Imports System Imports System.Reflection Class EqType Public Shared Sub Main() Dim a As Type = GetType(EqType) Dim b As Type = GetType(Type) Console.WriteLine("{0}", a.Equals(b).ToString()) b = (New EqType()).GetType() Console.WriteLine("{0}", a.Equals(b).ToString()) End Sub End Class [C#] using System; using System.Reflection; class EqType { public static void Main(String[] args) { Type a = typeof(EqType); Type b = typeof(Type); Console.WriteLine("{0}", a.Equals(b).ToString()); b = (new EqType()).GetType(); Console.WriteLine("{0}", a.Equals(b).ToString()); } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; __gc class EqType { }; int main() { Type* a = __typeof(EqType); Type* b = __typeof(Type); Console::WriteLine(S"{0}", __box(a->Equals(b))); b = (new EqType())->GetType(); Console::WriteLine(S"{0}", __box(a->Equals(b))); } [JScript] import System; import System.Reflection; class EqType { public static function Main() : void { var a = EqType; var b = Type; Console.WriteLine("{0}", a.Equals(b).ToString()); b = (new EqType).GetType(); Console.WriteLine("{0}", a.Equals(b).ToString()); } } EqType.Main();
This code produces the following output:
False
True
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
Type Class | Type Members | System Namespace | Type.Equals Overload List | UnderlyingSystemType