次の方法で共有


UInt32.Equals メソッド

対象のインスタンスが、指定したオブジェクトに等しいかどうかを示す値を返します。

UInt32 型は CLS との互換性がありません。CLS との互換性が必要な場合は、代わりに Int64 を使用してください。Int32 は、元の値が UInt32.MaxValue の半分以下の場合に使用されます。CLS との互換性に関する詳細については 「共通言語仕様の概要」 を参照してください。

Overrides Public Function Equals( _
   ByVal obj As Object _) As Boolean
[C#]
public override bool Equals(objectobj);
[C++]
public: bool Equals(Object* obj);
[JScript]
public override function Equals(
   obj : Object) : Boolean;

パラメータ

  • obj
    このインスタンスと比較するオブジェクト。

戻り値

objUInt32 のインスタンスで、このインスタンスの値に等しい場合は true 。それ以外の場合は false

使用例

[Visual Basic, C#, C++] Equals メソッドを次のサンプルで示します。

 
Dim myVariable1 As UInt32 = UInt32.Parse(20)
Dim myVariable2 As UInt32 = UInt32.Parse(20)

' Display the declaring type.
Console.WriteLine(ControlChars.NewLine + "Type of 'myVariable1' is '{0}' and" +  _ 
         " value is :{1}", myVariable1.GetType().ToString(), myVariable1.ToString())
Console.WriteLine("Type of 'myVariable2' is '{0}' and" +  _
      " value is :{1}", myVariable2.GetType().ToString(), myVariable2.ToString())
' Compare 'myVariable1' instance with 'myVariable2' Object.
If myVariable1.Equals(myVariable2) Then
   Console.WriteLine(ControlChars.NewLine + "Structures 'myVariable1' and" +  _
      " 'myVariable2' are equal")
Else
   Console.WriteLine(ControlChars.NewLine + "Structures 'myVariable1' and" +  _
         " 'myVariable2' are not equal")
End If

[C#] 
UInt32 myVariable1 = 20;
UInt32 myVariable2 = 20;

// Display the declaring type.
Console.WriteLine("\nType of 'myVariable1' is '{0}' and"+
     " value is :{1}",myVariable1.GetType(), myVariable1); 
Console.WriteLine("Type of 'myVariable2' is '{0}' and"+
     " value is :{1}",myVariable2.GetType(), myVariable2);

// Compare 'myVariable1' instance with 'myVariable2' Object.
if( myVariable1.Equals( myVariable2 ) )
   Console.WriteLine( "\nStructures 'myVariable1' and "+
         "'myVariable2' are equal");
else
   Console.WriteLine( "\nStructures 'myVariable1' and "+
         "'myVariable2' are not equal");

[C++] 
UInt32 myVariable1 = 20;
UInt32 myVariable2 = 20;

// Display the declaring type.
Console::WriteLine(S"\nType of 'myVariable1' is '{0}' and  value is : {1}", __box(myVariable1)->GetType(), __box(myVariable1));
Console::WriteLine(S"Type of 'myVariable2' is '{0}' and  value is : {1}", __box(myVariable2)->GetType(), __box(myVariable2));

// Compare 'myVariable1' instance with 'myVariable2' Object.
if (__box(myVariable1)->Equals(__box(myVariable2)))
   Console::WriteLine(S"\nStructures 'myVariable1' and 'myVariable2' are equal");
else
   Console::WriteLine(S"\nStructures 'myVariable1' and 'myVariable2' are not equal");

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: 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

参照

UInt32 構造体 | UInt32 メンバ | System 名前空間 | CompareTo