Performing OR between BitArray instances of different sizes returns an exception : BitArray « Collections Data Structure « C# / C Sharp






Performing OR between BitArray instances of different sizes returns an exception

 

 using System;
 using System.Collections;
 public class SamplesBitArray  {
    public static void Main()  {
       BitArray myBA1 = new BitArray( 4 );
       BitArray myBA2 = new BitArray( 4 );
       myBA1[0] = myBA1[1] = false;
       myBA1[2] = myBA1[3] = true;
       myBA2[0] = myBA2[2] = false;
       myBA2[1] = myBA2[3] = true;


       try  {
          BitArray myBA3 = new BitArray( 8 );
          myBA3[0] = myBA3[1] = myBA3[2] = myBA3[3] = false;
          myBA3[4] = myBA3[5] = myBA3[6] = myBA3[7] = true;
          myBA1.Or( myBA3 );
       } catch ( Exception myException )  {
          Console.WriteLine("Exception: " + myException.ToString());
       }
    }

 }

   
  








Related examples in the same category

1.Demonstrate BitArrayDemonstrate BitArray
2.Use BitArray collection as Flag
3.illustrates the use of a BitArrayillustrates the use of a BitArray
4.illustrates the use of BitArray methodsillustrates the use of BitArray methods
5.BitArray Class manages a compact array of bit values
6.Displays the properties and values of the BitArrays
7.BitArray.CopyTo copies the entire BitArray to a compatible one-dimensional Array
8.Gets the value of the bit at a specific position in the BitArray.
9.Inverts all the bit values in the current BitArray
10.Performs the bitwise OR operation
11.Performs bitwise exclusive OR operation