BitArray.CopyTo Method (Array, Int32)


Copies the entire BitArray to a compatible one-dimensional Array, starting at the specified index of the target array.

Namespace:   System.Collections
Assembly:  mscorlib (in mscorlib.dll)

abstract CopyTo : 
        array:Array *
        index:int -> unit
override CopyTo : 
        array:Array *
        index:int -> unit


Type: System.Array

The one-dimensional Array that is the destination of the elements copied from BitArray. The Array must have zero-based indexing.

Type: System.Int32

The zero-based index in array at which copying begins.

Exception Condition

array is null.


index is less than zero.


array is multidimensional.


The number of elements in the source BitArray is greater than the available space from index to the end of the destination array.


The type of the source BitArray cannot be cast automatically to the type of the destination array.

The specified array must be of a compatible type. Only bool, int, and byte types of arrays are supported.

This method uses Array.Copy to copy the elements.

This method is an O(n) operation, where n is Count.

The following code example shows how to copy a BitArray into a one-dimensional Array.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top