Mono Class Library: System.Collections.BitArray Overview | Members

System.Collections.BitArray Constructor

Constructs and initializes a new instance of the BitArray class where the inital values are set by the byte array.

public BitArray (byte[] bytes)

Parameters

bytes
An Array of Bytes.

Remarks

When using this constructor the new instance will allows have a Count that is 8 (i.e. the length of 1 Byte) times the length of the Byte array.

C# Example

using System;
using System.Collections;


        public class BitArrayFromByteArray
        {
                public static void Main ()
                {
                        BitArray bitArray = new BitArray (new byte [] {byte.Parse ("25")});
                        Console.WriteLine ("bitArray.Count: {0}", bitArray.Count);
                        for (int i = 0; i < bitArray.Count; i++)
                                Console.WriteLine ("bitArray [{0}]: {1}", i, bitArray [i]);
                }
        }
  

Compiling and running the above example generates the following output:

bitArray.Count: 8

bitArray [0]: True

bitArray [1]: False

bitArray [2]: False

bitArray [3]: True

bitArray [4]: True

bitArray [5]: False

bitArray [6]: False

bitArray [7]: False

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0