Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Collections.​BitArray
Assembly: System.Collections
Inheritance: object → BitArray
Implemented Interfaces
- ICollection (Inherits: IEnumerable)
- ICloneable
Manages a compact array of bit values, which are represented as Booleans, where <see langword="true" /> indicates that the bit is on (1) and <see langword="false" /> indicates the bit is off (0).
Properties
public
int
Count
Gets the number of elements contained in the <see cref="T:System.Collections.BitArray" /> .
public
bool
IsReadOnly
Gets a value indicating whether the <see cref="T:System.Collections.BitArray" /> is read-only.
public
bool
IsSynchronized
Gets a value indicating whether access to the <see cref="T:System.Collections.BitArray" /> is synchronized (thread safe).
public
bool
Item
public
int
Length
Gets or sets the number of elements in the <see cref="T:System.Collections.BitArray" /> .
public
object
SyncRoot
Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.BitArray" /> .
Methods
public
BitArray
And​(BitArray value)
Performs the bitwise AND operation between the elements of the current <see cref="T:System.Collections.BitArray" /> object and the corresponding elements in the specified array. The current <see cref="T:System.Collections.BitArray" /> object will be modified to store the result of the bitwise AND operation.
Returns An array containing the result of the bitwise AND operation, which is a reference to the current <see cref="T:System.Collections.BitArray" /> object.
value
The array with which to perform the bitwise AND operation.
public
object
Clone​()
Creates a shallow copy of the <see cref="T:System.Collections.BitArray" /> .
Returns A shallow copy of the <see cref="T:System.Collections.BitArray" /> .
public
void
CopyTo​(Array array,
int index)
Copies the entire <see cref="T:System.Collections.BitArray" /> to a compatible one-dimensional <see cref="T:System.Array" /> , starting at the specified index of the target array.
array
The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.BitArray" /> . The <see cref="T:System.Array" /> must have zero-based indexing.
index
The zero-based index in <paramref name="array" /> at which copying begins.
public
bool
Get​(int index)
Gets the value of the bit at a specific position in the <see cref="T:System.Collections.BitArray" /> .
Returns The value of the bit at position <paramref name="index" /> .
index
The zero-based index of the value to get.
public
IEnumerator
GetEnumerator​()
Returns an enumerator that iterates through the <see cref="T:System.Collections.BitArray" /> .
Returns An <see cref="T:System.Collections.IEnumerator" /> for the entire <see cref="T:System.Collections.BitArray" /> .
public
bool
HasAllSet​()
Determines whether all bits in the <see cref="T:System.Collections.BitArray" /> are set to <see langword="true" /> .
Returns <see langword="true" /> if every bit in the <see cref="T:System.Collections.BitArray" /> is set to <see langword="true" /> , or if <see cref="T:System.Collections.BitArray" /> is empty; otherwise, <see langword="false" /> .
public
bool
HasAnySet​()
Determines whether any bit in the <see cref="T:System.Collections.BitArray" /> is set to <see langword="true" /> .
Returns <see langword="true" /> if <see cref="T:System.Collections.BitArray" /> is not empty and at least one of its bit is set to <see langword="true" /> ; otherwise, <see langword="false" /> .
public
BitArray
LeftShift​(int count)
Shifts all the bit values of the current <see cref="T:System.Collections.BitArray" /> to the left on <paramref name="count" /> bits.
Returns The current <see cref="T:System.Collections.BitArray" /> .
count
The number of shifts to make for each bit.
public
BitArray
Not​()
Inverts all the bit values in the current <see cref="T:System.Collections.BitArray" /> , so that elements set to <see langword="true" /> are changed to <see langword="false" /> , and elements set to <see langword="false" /> are changed to <see langword="true" /> .
Returns The current instance with inverted bit values.
public
BitArray
Or​(BitArray value)
Performs the bitwise OR operation between the elements of the current <see cref="T:System.Collections.BitArray" /> object and the corresponding elements in the specified array. The current <see cref="T:System.Collections.BitArray" /> object will be modified to store the result of the bitwise OR operation.
Returns An array containing the result of the bitwise OR operation, which is a reference to the current <see cref="T:System.Collections.BitArray" /> object.
value
The array with which to perform the bitwise OR operation.
public
BitArray
RightShift​(int count)
Shifts all the bit values of the current <see cref="T:System.Collections.BitArray" /> to the right on <paramref name="count" /> bits.
Returns The current <see cref="T:System.Collections.BitArray" /> .
count
The number of shifts to make for each bit.
public
void
Set​(int index,
bool value)
Sets the bit at a specific position in the <see cref="T:System.Collections.BitArray" /> to the specified value.
index
The zero-based index of the bit to set.
value
The Boolean value to assign to the bit.
public
void
SetAll​(bool value)
Sets all bits in the <see cref="T:System.Collections.BitArray" /> to the specified value.
value
The Boolean value to assign to all bits.
public
BitArray
Xor​(BitArray value)
Performs the bitwise exclusive OR operation between the elements of the current <see cref="T:System.Collections.BitArray" /> object against the corresponding elements in the specified array. The current <see cref="T:System.Collections.BitArray" /> object will be modified to store the result of the bitwise exclusive OR operation.
Returns An array containing the result of the bitwise exclusive OR operation, which is a reference to the current <see cref="T:System.Collections.BitArray" /> object.
value
The array with which to perform the bitwise exclusive OR operation.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object