BitVector32.Equals メソッド
指定したオブジェクトが BitVector32 と等しいかどうかを判断します。
Overrides Public Function Equals( _
ByVal o As Object _) As Boolean
[C#]
public override bool Equals(objecto);
[C++]
public: bool Equals(Object* o);
[JScript]
public override function Equals(
o : Object) : Boolean;
パラメータ
- o
現在の BitVector32 と比較するオブジェクト。
戻り値
指定したオブジェクトが BitVector32 に等しい場合は true 。それ以外の場合は false 。
解説
o の型が BitVector32 の型と互換性がある場合、および o の値が Data の値に等しい場合、オブジェクト o は BitVector32 に等しいと見なされます。
使用例
[Visual Basic, C#, C++] BitVector32 を別の BitVector32 や Int32 と比較する方法については、次のコード例を参照してください。
Imports System
Imports System.Collections.Specialized
Public Class SamplesBitVector32
Public Shared Sub Main()
' Creates and initializes a BitVector32 with the value 123.
' This is the BitVector32 that will be compared to different types.
Dim myBV As New BitVector32(123)
' Creates and initializes a new BitVector32 which will be set up as sections.
Dim myBVsect As New BitVector32(0)
' Compares myBV and myBVsect.
Console.WriteLine("myBV : {0}", myBV.ToString())
Console.WriteLine("myBVsect : {0}", myBVsect.ToString())
If myBV.Equals(myBVsect) Then
Console.WriteLine(" myBV({0}) equals myBVsect({1}).", myBV.Data, myBVsect.Data)
Else
Console.WriteLine(" myBV({0}) does not equal myBVsect({1}).", myBV.Data, myBVsect.Data)
End If
Console.WriteLine()
' Assigns values to the sections of myBVsect.
Dim mySect1 As BitVector32.Section = BitVector32.CreateSection(5)
Dim mySect2 As BitVector32.Section = BitVector32.CreateSection(1, mySect1)
Dim mySect3 As BitVector32.Section = BitVector32.CreateSection(20, mySect2)
myBVsect(mySect1) = 3
myBVsect(mySect2) = 1
myBVsect(mySect3) = 7
' Compares myBV and myBVsect.
Console.WriteLine("myBV : {0}", myBV.ToString())
Console.WriteLine("myBVsect with values : {0}", myBVsect.ToString())
If myBV.Equals(myBVsect) Then
Console.WriteLine(" myBV({0}) equals myBVsect({1}).", myBV.Data, myBVsect.Data)
Else
Console.WriteLine(" myBV({0}) does not equal myBVsect({1}).", myBV.Data, myBVsect.Data)
End If
Console.WriteLine()
' Compare myBV with an Int32.
Console.WriteLine("Comparing myBV with an Int32: ")
Dim myInt32 As Int32 = 123
' Using Equals will fail because Int32 is not compatible with BitVector32.
If myBV.Equals(myInt32) Then
Console.WriteLine(" Using BitVector32.Equals, myBV({0}) equals myInt32({1}).", myBV.Data, myInt32)
Else
Console.WriteLine(" Using BitVector32.Equals, myBV({0}) does not equal myInt32({1}).", myBV.Data, myInt32)
End If ' To compare a BitVector32 with an Int32, use the "==" operator.
If myBV.Data = myInt32 Then
Console.WriteLine(" Using the ""=="" operator, myBV.Data({0}) equals myInt32({1}).", myBV.Data, myInt32)
Else
Console.WriteLine(" Using the ""=="" operator, myBV.Data({0}) does not equal myInt32({1}).", myBV.Data, myInt32)
End If
End Sub 'Main
End Class 'SamplesBitVector32
' This code produces the following output.
'
' myBV : BitVector32{00000000000000000000000001111011}
' myBVsect : BitVector32{00000000000000000000000000000000}
' myBV(123) does not equal myBVsect(0).
'
' myBV : BitVector32{00000000000000000000000001111011}
' myBVsect with values : BitVector32{00000000000000000000000001111011}
' myBV(123) equals myBVsect(123).
'
' Comparing myBV with an Int32:
' Using BitVector32.Equals, myBV(123) does not equal myInt32(123).
' Using the "==" operator, myBV.Data(123) equals myInt32(123).
[C#]
using System;
using System.Collections.Specialized;
public class SamplesBitVector32 {
public static void Main() {
// Creates and initializes a BitVector32 with the value 123.
// This is the BitVector32 that will be compared to different types.
BitVector32 myBV = new BitVector32( 123 );
// Creates and initializes a new BitVector32 which will be set up as sections.
BitVector32 myBVsect = new BitVector32( 0 );
// Compares myBV and myBVsect.
Console.WriteLine( "myBV : {0}", myBV.ToString() );
Console.WriteLine( "myBVsect : {0}", myBVsect.ToString() );
if ( myBV.Equals( myBVsect ) )
Console.WriteLine( " myBV({0}) equals myBVsect({1}).", myBV.Data, myBVsect.Data );
else
Console.WriteLine( " myBV({0}) does not equal myBVsect({1}).", myBV.Data, myBVsect.Data );
Console.WriteLine();
// Assigns values to the sections of myBVsect.
BitVector32.Section mySect1 = BitVector32.CreateSection( 5 );
BitVector32.Section mySect2 = BitVector32.CreateSection( 1, mySect1 );
BitVector32.Section mySect3 = BitVector32.CreateSection( 20, mySect2 );
myBVsect[mySect1] = 3;
myBVsect[mySect2] = 1;
myBVsect[mySect3] = 7;
// Compares myBV and myBVsect.
Console.WriteLine( "myBV : {0}", myBV.ToString() );
Console.WriteLine( "myBVsect with values : {0}", myBVsect.ToString() );
if ( myBV.Equals( myBVsect ) )
Console.WriteLine( " myBV({0}) equals myBVsect({1}).", myBV.Data, myBVsect.Data );
else
Console.WriteLine( " myBV({0}) does not equal myBVsect({1}).", myBV.Data, myBVsect.Data );
Console.WriteLine();
// Compare myBV with an Int32.
Console.WriteLine( "Comparing myBV with an Int32: " );
Int32 myInt32 = 123;
// Using Equals will fail because Int32 is not compatible with BitVector32.
if ( myBV.Equals( myInt32 ) )
Console.WriteLine( " Using BitVector32.Equals, myBV({0}) equals myInt32({1}).", myBV.Data, myInt32 );
else
Console.WriteLine( " Using BitVector32.Equals, myBV({0}) does not equal myInt32({1}).", myBV.Data, myInt32 );
// To compare a BitVector32 with an Int32, use the "==" operator.
if ( myBV.Data == myInt32 )
Console.WriteLine( " Using the \"==\" operator, myBV.Data({0}) equals myInt32({1}).", myBV.Data, myInt32 );
else
Console.WriteLine( " Using the \"==\" operator, myBV.Data({0}) does not equal myInt32({1}).", myBV.Data, myInt32 );
}
}
/*
This code produces the following output.
myBV : BitVector32{00000000000000000000000001111011}
myBVsect : BitVector32{00000000000000000000000000000000}
myBV(123) does not equal myBVsect(0).
myBV : BitVector32{00000000000000000000000001111011}
myBVsect with values : BitVector32{00000000000000000000000001111011}
myBV(123) equals myBVsect(123).
Comparing myBV with an Int32:
Using BitVector32.Equals, myBV(123) does not equal myInt32(123).
Using the "==" operator, myBV.Data(123) equals myInt32(123).
*/
[C++]
#using <mscorlib.dll>
#using <system.dll>
using namespace System;
using namespace System::Collections::Specialized;
int main()
{
// Creates and initializes a BitVector32 with the value 123.
// This is the BitVector32 that will be compared to different types.
BitVector32 myBV(123);
// Creates and initializes a new BitVector32 which will be set up as sections.
BitVector32 myBVsect(0);
// Compares myBV and myBVsect.
Console::WriteLine(S"myBV : {0}", __box(myBV));
Console::WriteLine(S"myBVsect : {0}", __box(myBVsect));
if (myBV.Equals(__box(myBVsect)))
Console::WriteLine(S" myBV( {0}) equals myBVsect( {1}).", __box(myBV.Data), __box(myBVsect.Data));
else
Console::WriteLine(S" myBV( {0}) does not equal myBVsect( {1}).", __box(myBV.Data), __box(myBVsect.Data));
Console::WriteLine();
// Assigns values to the sections of myBVsect.
BitVector32::Section mySect1 = BitVector32::CreateSection(5);
BitVector32::Section mySect2 = BitVector32::CreateSection(1, mySect1);
BitVector32::Section mySect3 = BitVector32::CreateSection(20, mySect2);
myBVsect.Item[mySect1] = 3;
myBVsect.Item[mySect2] = 1;
myBVsect.Item[mySect3] = 7;
// Compares myBV and myBVsect.
Console::WriteLine(S"myBV : {0}", __box(myBV));
Console::WriteLine(S"myBVsect with values : {0}", __box(myBVsect));
if (myBV.Equals(__box(myBVsect)))
Console::WriteLine(S" myBV( {0}) equals myBVsect( {1}).", __box(myBV.Data), __box(myBVsect.Data));
else
Console::WriteLine(S" myBV( {0}) does not equal myBVsect( {1}).", __box(myBV.Data), __box(myBVsect.Data));
Console::WriteLine();
// Compare myBV with an Int32.
Console::WriteLine(S"Comparing myBV with an Int32: ");
Int32 myInt32 = 123;
// Using Equals will fail because Int32 is not compatible with BitVector32.
if (myBV.Equals(__box(myInt32)))
Console::WriteLine(S" Using BitVector32::Equals, myBV( {0}) equals myInt32( {1}).", __box(myBV.Data), __box(myInt32));
else
Console::WriteLine(S" Using BitVector32::Equals, myBV( {0}) does not equal myInt32( {1}).", __box(myBV.Data), __box(myInt32));
// To compare a BitVector32 with an Int32, use the "==" operator.
if (myBV.Data == myInt32)
Console::WriteLine(S" Using the \"==\" operator, myBV.Data( {0}) equals myInt32( {1}).", __box(myBV.Data), __box(myInt32));
else
Console::WriteLine(S" Using the \"==\" operator, myBV.Data( {0}) does not equal myInt32( {1}).", __box(myBV.Data), __box(myInt32));
}
/*
This code produces the following output.
myBV : BitVector32 {00000000000000000000000001111011}
myBVsect : BitVector32 {00000000000000000000000000000000}
myBV(123) does not equal myBVsect(0).
myBV : BitVector32 {00000000000000000000000001111011}
myBVsect with values : BitVector32 {00000000000000000000000001111011}
myBV(123) equals myBVsect(123).
Comparing myBV with an Int32:
Using BitVector32::Equals, myBV(123) does not equal myInt32(123).
Using the "==" operator, myBV.Data(123) equals myInt32(123).
*/
[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
参照
BitVector32 構造体 | BitVector32 メンバ | System.Collections.Specialized 名前空間