To obtain items from this collection, use an integer index gartic phone. The indexes in this collection are entirely zero-based.
Constructors CONSTRUCTOR DESCRIPTION BitArray(BitArray) Initializes a new instance of the BitArray class that contains bit values copied from the specified BitArray. BitArray(Boolean[]) Initializes a new instance of the BitArray class that contains bit values copied from the specified array of Booleans. BitArray(Byte[]) Initializes a new instance of the BitArray class that contains bit values copied from the specified array of bytes. BitArray(Int32) Initializes a new instance of the BitArray class that can hold the specified number of bit values, which are initially set to false. BitArray(Int32, Boolean) Initializes a new instance of the BitArray class that can hold the specified number of bit values, which are initially set to the specified value. BitArray(Int32[]) Initializes a new instance of the BitArray class that contains bit values copied from the specified array of 32-bit integers.
The BitArray class manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on i.e, 1 and false indicates the bit is off i.e, 0. This class is contained in System.Collections namespace.Properties of BitArray Class:The BitArray class is a collection class in which the capacity is always the same as the count. Elements are added to a BitArray by increasing the Length property. Elements are deleted by decreasing the Length property. Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based.public static void Main() { // Creating a BitArray BitArray myBitArr = new BitArray(5); myBitArr[0] = true; myBitArr[1] = true; myBitArr[2] = false; myBitArr[3] = true; myBitArr[4] = false; // To get the value of index at index 2 Console.WriteLine(myBitArr.Get(2)); // To get the value of index at index 3 Console.WriteLine(myBitArr.Get(3)); }