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

Type.Equals Method (Type)

Determines if the underlying system type of the current Type is the same as the underlying system type of the specified Type.

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

public bool Equals (
	Type o
)
public final boolean Equals (
	Type o
)
public final function Equals (
	o : Type
) : boolean

Parameters

o

The Type 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.

The following example uses Equals to compare two types.

using System;
using System.Reflection;

class EqType
{
  public static void Main(String[] args)
  {
   int a = 1;
   float b = 1;
   Console.WriteLine("{0}", a.Equals(b).ToString());
   b=a;
   Console.WriteLine("{0}", a.Equals(b).ToString());
  }
}

//This code produces the following output:
//False
//False

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

class EqType
{
    public static void main(String[] args)
    {
        int a = 1;
        float b = 1;
        Console.WriteLine("{0}", System.Convert.ToString 
            (((Int32)(a)).Equals(System.Convert.ToDecimal(b))));
        b = a;
        Console.WriteLine("{0}", System.Convert.ToString
            (((Int32)(a)).Equals(System.Convert.ToDecimal(b))));
        
    } //main
} //EqType

//This code produces the following output:
//False
//False

import System;
import System.Reflection;

class EqType
{
  public static function Main() : void 
  {
   var a : int= 1;
   var b : float = 1;
   Console.WriteLine("{0}", a.Equals(b).ToString());
   b=float(a);
   Console.WriteLine("{0}", a.Equals(b).ToString());
  }
}
EqType.Main();
//This code produces the following output:
//False
//False

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.