Bit Array

The BitArray is a collection exclusively for binary values. We can access the elements
using the index like an ArrayList.

Example 5:

 

using System;
namespace SampleProgram {
  class MySample {
    public static void Main(string[] args) {
      BitArray bitArray = new BitArray(8);
      byte[] a = {
        15
      };
      bitArray = new BitArray(a);
      Console.WriteLine( " The Bit array in binary: ");
      for (int i = 0; i < bitArray.Count; i++) {
        Console.Write( " {
          0,
          -6
        } ", bitArray[i]);
      }
    }
  }
}

 

The output will be:

The Bit array in binary: 15
True True True True False False False

 

 

Related Tutorials