System.Array.CopyTo Method

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.

Syntax

[System.Runtime.InteropServices.ComVisible(false)]
public void CopyTo (Array array, long index)

Parameters

array
The one-dimensional array that is the destination of the elements copied from the current array.
index
A 64-bit integer that represents the index in array at which copying begins.

Remarks

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 ICollection interface. If implementing ICollection is not explicitly required, use Array.Copy(Array, Array, long) 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 Array.Length. It performs a shallow copy only.

Requirements

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