CSharp examples for Collection:BitArray
demonstrates the use of BitArray class
using System;/*from www. ja va 2s. c o m*/ using System.Collections; class Program { static void Main(string[] args) { //creating two bit arrays of size 8 BitArray ba1 = new BitArray(8); BitArray ba2 = new BitArray(8); byte[] a = { 60 }; byte[] b = { 13 }; ba1 = new BitArray(a); ba2 = new BitArray(b); for (int i = 0; i < ba1.Count; i++) { Console.Write("{0, -6} ", ba1[i]); } for (int i = 0; i < ba2.Count; i++) { Console.Write("{0, -6} ", ba2[i]); } BitArray ba3 = new BitArray(8); ba3 = ba1.And(ba2); for (int i = 0; i < ba3.Count; i++) { Console.Write("{0, -6} ", ba3[i]); } ba3 = ba1.Or(ba2); for (int i = 0; i < ba3.Count; i++) { Console.Write("{0, -6} ", ba3[i]); } } }