Demonstrate BitArray : BitArray « Collections Data Structure « C# / C Sharp

Demonstrate BitArray

Demonstrate BitArray
// Demonstrate BitArray. 
using System; 
using System.Collections; 
public class BADemo { 
  public static void showbits(string rem, 
                         BitArray bits) { 
    for(int i=0; i < bits.Count; i++) 
      Console.Write("{0, -6} ", bits[i]); 
  public static void Main() { 
    BitArray ba = new BitArray(8); 
    byte[] b = { 67 }; 
    BitArray ba2 = new BitArray(b); 
    showbits("Original contents of ba:", ba); 
    ba = ba.Not(); 
    showbits("Contents of ba after Not:", ba); 
    showbits("Contents of ba2:", ba2); 
    BitArray ba3 = ba.Xor(ba2); 
    showbits("Result of ba XOR ba2:", ba3); 


Related examples in the same category

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