Esta documentación está archivada y no tiene mantenimiento.

BitVector32.Equals (Método) (Object)

Determina si el objeto especificado es igual a BitVector32.

Espacio de nombres: System.Collections.Specialized
Ensamblado: System (en system.dll)

public override bool Equals (
	Object o
)
public boolean Equals (
	Object o
)
public override function Equals (
	o : Object
) : boolean
No aplicable.

Parámetros

o

Objeto que se va a comparar con la estructura BitVector32 actual.

Valor devuelto

Es true si el objeto especificado es igual a BitVector32; en caso contrario, es false.

El objeto o se considera igual a BitVector32 si el tipo de o es compatible con el tipo BitVector32 y si el valor de o es igual al valor de Data.

Este método es una operación O(1).

En el siguiente código de ejemplo se compara un BitVector32 con otro BitVector32 y con un Int32.

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

*/

import System.*;
import System.Collections.Specialized.*;

public class SamplesBitVector32
{
    public static void main(String[] args)
    {
        // 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}).",
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myBVsect.get_Data()));
        }
        else {
            Console.WriteLine("   myBV({0}) does not equal myBVsect({1}).", 
                System.Convert.ToString(myBV.get_Data()), 
                System.Convert.ToString(myBVsect.get_Data()));
        }
        Console.WriteLine();
          
        // Assigns values to the sections of myBVsect.
        BitVector32.Section mySect1 = BitVector32.CreateSection((short)5);
        BitVector32.Section mySect2 = 
            BitVector32.CreateSection((short)1, mySect1);
        BitVector32.Section mySect3 = 
            BitVector32.CreateSection((short)20, mySect2);
        myBVsect.set_Item(mySect1 , 3);
        myBVsect.set_Item(mySect2 , 1);
        myBVsect.set_Item(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}).",
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myBVsect.get_Data()));
        }
        else {
            Console.WriteLine("   myBV({0}) does not equal myBVsect({1}).",
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myBVsect.get_Data()));
        }
        Console.WriteLine();
          
        // Compare myBV with an Int32.
        Console.WriteLine("Comparing myBV with an Int32: ");
        Int32 myInt32 = (Int32)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}).", 
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myInt32));
        }
        else {
            Console.WriteLine("   Using BitVector32.Equals, myBV({0}) "
                + "does not equal myInt32({1}).", 
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myInt32));
        } // To compare a BitVector32 with an Int32, use the "==" operator.
        if (myBV.get_Data() == (int)myInt32) {
            Console.WriteLine("   Using the \"==\" operator, myBV.Data({0})"
                + " equals myInt32({1}).", 
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myInt32));
        }
        else {
            Console.WriteLine("   Using the \"==\" operator, myBV.Data({0})"
                + " does not equal myInt32({1}).", 
                System.Convert.ToString(myBV.get_Data()),
                System.Convert.ToString(myInt32));
        } 
    } //main
} //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).

*/

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0, 1.0

XNA Framework

Compatible con: 1.0
Mostrar: