C# Type Equals(Type)
Description
Type Equals(Type)
determines if the underlying system
type of the current Type is the same as the underlying system type of the specified
Type.
Syntax
Type.Equals(Type)
has the following syntax.
public virtual bool Equals(
Type o
)
Parameters
Type.Equals(Type)
has the following parameters.
o
- The object whose underlying system type is to be compared with the underlying system type of the current Type.
Returns
Type.Equals(Type)
method returns 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.
/*from w w w .j ava 2 s . c om*/
using System;
using System.Reflection;
class Example
{
public static void Main()
{
Type a = typeof(System.String);
Type b = typeof(System.Int32);
a = typeof(Example);
b = new Example().GetType();
Console.WriteLine("{0} is equal to {1}: {2}", a, b, a.Equals(b));
b = typeof(Type);
Console.WriteLine("typeof({0}).Equals(typeof({1})): {2}", a, b, a.Equals(b));
}
}
The code above generates the following result.