Manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0).
Assembly: mscorlib (in mscorlib.dll)
Thetype exposes the following members.
|BitArray(BitArray)||Initializes a new instance of the class that contains bit values copied from the specified .|
|BitArray(Boolean)||Initializes a new instance of the class that contains bit values copied from the specified array of Booleans.|
|BitArray(Byte)||Initializes a new instance of the class that contains bit values copied from the specified array of bytes.|
|BitArray(Int32)||Initializes a new instance of the class that can hold the specified number of bit values, which are initially set to false.|
|BitArray(Int32)||Initializes a new instance of the class that contains bit values copied from the specified array of 32-bit integers.|
|BitArray(Int32, Boolean)||Initializes a new instance of the class that can hold the specified number of bit values, which are initially set to the specified value.|
|Count||Gets the number of elements contained in the .|
|IsReadOnly||Gets a value indicating whether the is read-only.|
|IsSynchronized||Gets a value indicating whether access to the is synchronized (thread safe).|
|Item||Gets or sets the value of the bit at a specific position in the .|
|Length||Gets or sets the number of elements in the .|
|SyncRoot||Gets an object that can be used to synchronize access to the .|
|And||Performs the bitwise AND operation on the elements in the current against the corresponding elements in the specified .|
|Clone||Creates a shallow copy of the .|
|CopyTo||Copies the entire to a compatible one-dimensional Array, starting at the specified index of the target array.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Get||Gets the value of the bit at a specific position in the .|
|GetEnumerator||Returns an enumerator that iterates through the .|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|Not||Inverts all the bit values in the current , so that elements set to true are changed to false, and elements set to false are changed to true.|
|Or||Performs the bitwise OR operation on the elements in the current against the corresponding elements in the specified .|
|Set||Sets the bit at a specific position in the to the specified value.|
|SetAll||Sets all bits in the to the specified value.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|Xor||Performs the bitwise exclusive OR operation on the elements in the current against the corresponding elements in the specified .|
|AsParallel||Enables parallelization of a query. (Defined by ParallelEnumerable.)|
|AsQueryable||Converts an IEnumerable to an IQueryable. (Defined by Queryable.)|
|Cast(TResult)||Casts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)|
|OfType(TResult)||Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)|
|ICollection.CopyTo||Copies the elements of the to an Array, starting at the specified Array index.|
|ICollection.Count||Gets the number of elements in the .|
|ICollection.IsSynchronized||Gets a value that indicates whether access to the is synchronized (thread safe).|
|ICollection.SyncRoot||Gets an object that can be used to synchronize access to the .|
The class is a collection class in which the capacity is always the same as the count. Elements are added to a by increasing the Length property; elements are deleted by decreasing the Length property. The size of a is controlled by the client; indexing past the end of the throws an ArgumentException.The class provides methods that are not found in other collections, including those that allow multiple elements to be modified at once using a filter, such as And, Or, Xor , Not, and SetAll.
The BitVector32 class is a structure that provides the same functionality as , but with faster performance. BitVector32 is faster because it is a value type and therefore allocated on the stack, whereas is a reference type and, therefore, allocated on the heap.
System.Collections.Specialized.BitVector32 can store exactly 32 bits, whereas can store a variable number of bits. BitVector32 stores both bit flags and small integers, thereby making it ideal for data that is not exposed to the user. However, if the number of required bit flags is unknown, is variable, or is greater than 32, use instead.
Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based.
.NET FrameworkSupported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
This implementation does not provide a synchronized (thread safe) wrapper for a .
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.