Array.CopyTo Method (Array, Int64)
Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index. The index is specified as a 64-bit integer.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- array
-
Type:
System.Array
The one-dimensional array that is the destination of the elements copied from the current array.
- index
-
Type:
System.Int64
A 64-bit integer that represents the index in array at which copying begins.
| Exception | Condition |
|---|---|
| ArgumentNullException | array is null. |
| ArgumentOutOfRangeException | index is outside the range of valid indexes for array. |
| ArgumentException | array is multidimensional. -or- The number of elements in the source array is greater than the available number of elements from index to the end of the destination array. |
| ArrayTypeMismatchException | The type of the source Array cannot be cast automatically to the type of the destination array. |
| RankException | The source Array is multidimensional. |
| InvalidCastException | At least one element in the source Array cannot be cast to the type of destination array. |
This method copies all the elements of the current array instance to the array destination array, starting at index index. The array destination array must already have been dimensioned and must have a sufficient number of elements to accommodate the copied elements. Otherwise, the method throws an exception.
This method supports the System.Collections.ICollection interface. If implementing System.Collections.ICollection is not explicitly required, use Copy to avoid an extra indirection.
If this method throws an exception while copying, the state of array is undefined.
This method is an O(n) operation, where n is Length.It performs a shallow copy only.
Available since 1.1