illustrates the use of a BitArray : BitArray « Collections Data Structure « C# / C Sharp






illustrates the use of a BitArray

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]);
    }

  }

}


           
         
  








Related examples in the same category

1.Demonstrate BitArrayDemonstrate BitArray
2.Use BitArray collection as Flag
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