using System;
using System.Collections;
public class BADemo {
public static void showbits(string rem,
BitArray bits) {
Console.WriteLine(rem);
for(int i=0; i < bits.Count; i++)
Console.Write("{0, -6} ", bits[i]);
Console.WriteLine("\n");
}
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);
}
}
|