Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Illustrates the use of a BitArray

/*   illustrates the use of a BitArray */ using System; using System.Collections; public class Example11_4 {   public static void Main()   {     // create a BitArray object     BitArray myBitArray = new BitArray(4);     // display the Length property     Console.WriteLine("myBitArray.Length = " +       myBitArray.Length);     // set the four elements of the BitArray     myBitArray[0] = false;     myBitArray[1] = true;     myBitArray[2] = true;     myBitArray[3] = false;     // display the elements of the BitArray     for (int counter = 0; counter < myBitArray.Count; counter++)     {       Console.WriteLine("myBitArray[" + counter + "] = " +         myBitArray[counter]);     }   } }