Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public override bool Equals (
	Object o
)
public boolean Equals (
	Object o
)
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.

This method overrides Object.Equals.

The following example uses Equals to compare two Object instances.

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());
    }
}

import System.*;
import System.Reflection.*;

class EqType
{
    public static void main(String[] args)
    {
        Type a = EqType.class.ToType();
        Type b = Type.class.ToType();
        Console.WriteLine("{0}", System.Convert.ToString(a.Equals(b)));
        b = (new EqType()).GetType();
        Console.WriteLine("{0}", System.Convert.ToString(a.Equals(b)));
    } //main
} //EqType

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.