C# BitArray BitArray(Byte[])

Description

BitArray BitArray(Byte[]) initializes a new instance of the BitArray class that contains bit values copied from the specified array of bytes.

Syntax

BitArray.BitArray(Byte[]) has the following syntax.


public BitArray(
  byte[] bytes
)

Parameters

BitArray.BitArray(Byte[]) has the following parameters.

  • bytes - An array of bytes containing the values to copy, where each byte represents eight consecutive bits.

Example


/* w w w .ja v  a 2 s .  c  om*/
using System;
using System.Collections;
public class SamplesBitArray  {
   public static void Main()  {
      BitArray myBA = new BitArray( new byte[]{0,0,0,1} );
      myBA[0] = myBA[1] = myBA[2] = myBA[3] = true;

      bool[] myBoolArray = new bool[8];
      myBoolArray[0] = false;
      myBoolArray[1] = false;

      myBA.CopyTo( myBoolArray, 3 );
   }

   public static void PrintValues( IEnumerable myArr )  {
      foreach ( Object obj in myArr ) {
         Console.WriteLine(obj );
      }
   }
}




















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack