C# BitArray BitArray(Boolean[])

Description

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

Syntax

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


public BitArray(
  bool[] values
)

Parameters

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

  • values - An array of Booleans to copy.

Example


/* ww  w .jav a  2s  . c om*/
using System;
using System.Collections;
public class SamplesBitArray
{
    public static void Main()
    {
        BitArray myBA = new BitArray(new Boolean[] { true, true, true, true });
        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