現在の Type の基になるシステム型が、指定した Type の基になるシステム型と同じかどうかを判断します。
Overloads Public Function Equals( _
ByVal o As Type _) As Boolean
[C#]
public bool Equals(Typeo);
[C++]
public: bool Equals(Type* o);
[JScript]
public function Equals(
o : Type) : Boolean;
パラメータ
- o
基になるシステム型が、現在の Type の基になるシステム型との比較対象になる Type 。
戻り値
o の基になるシステム型が現在の Type の基になるシステム型と同じである場合は true 。それ以外の場合は false 。
使用例
Equals を使用して 2 つの型を比較するコード例を次に示します。
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
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard
参照
Type クラス | Type メンバ | System 名前空間 | Type.Equals オーバーロードの一覧 | UnderlyingSystemType