Equals Method (Object)
Collapse the table of content
Expand the table of content

Type.Equals Method (Object)

 

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

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

override Equals : 
        o:Object -> bool

Parameters

o
Type: System.Object

The object whose underlying system type is to be compared with the underlying system type of the current Type. For the comparison to succeed, o must be able to be cast or converted to an object of type Type.

Return Value

Type: System.Boolean

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: .

  • o is null.

  • o cannot be cast or converted to a Type object.

This method overrides Object.Equals. It casts o to an object of type Type and calls the Type.Equals(Type) method.

The following example uses Equals(Object) to compare various Type object instances with various Object instances.

No code example is currently available or this language may not be supported.

Two things are particularly worth noting about the example:

  • The comparison of a Type object that represents an integer with a TypeInfo object that represents an integer return true because TypeInfo is derived from Type.

  • The comparison of a Type object that represents a IList<'T> object (an open generic type) with a List(Of String) object (a closed generic type) returns false.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft