Export (0) Print
Expand All

Type.Equals Method (Type)

.NET Framework 1.1

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

[Visual Basic]
Overloads Public Function Equals( _
   ByVal o As Type _
) As Boolean
[C#]
public bool Equals(
 Type o
);
[C++]
public: bool Equals(
 Type* o
);
[JScript]
public 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.

Example

The following example uses Equals to compare two types.

[Visual Basic] 
Imports System
Imports System.Reflection

Class EqType
    
    Public Shared Sub Main()
        Dim a As Integer = 1
        Dim b As Single = 1
        Console.WriteLine("{0}", a.Equals(b).ToString())
        b = a
        Console.WriteLine("{0}", a.Equals(b).ToString())
    End Sub
End Class

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

[C#] 
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

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;

int main()
{
    int a = 1;
    float b = 1;
    Console::WriteLine(S"{0}", __box(a.Equals(__box(b))));
    b = (float)a;
    Console::WriteLine(S"{0}", __box(a.Equals(__box(b))));
}

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

[JScript] 
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

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, Common Language Infrastructure (CLI) Standard

See Also

Type Class | Type Members | System Namespace | Type.Equals Overload List | UnderlyingSystemType

Show:
© 2014 Microsoft