System.Collections.BitArray.Length Property

Gets or sets the number of elements in the BitArray.

Syntax

public int Length { get; set; }

Value

A int that specifies the number of elements contained in the current instance.

Remarks

BitArray.Length and BitArray.Count return the same value. BitArray.Length can be set to a specific value, but BitArray.Count is read-only.

If BitArray.Length is set to a value that is less than BitArray.Count, the BitArray is truncated and the elements after the index value -1 are deleted.

If BitArray.Length is set to a value that is greater than BitArray.Count, the new elements are set to false.

Retrieving the value of this property is an O(1) operation. Setting this property is an O(n) operation.

Requirements

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