Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
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 32-bit integer.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub CopyTo ( _
array As Array, _
index As Integer _
)
public void CopyTo(
Array array,
int index
)
public:
virtual void CopyTo(
Array^ array,
int index
) sealed
abstract CopyTo :
array:Array *
index:int -> unit
override CopyTo :
array:Array *
index:int -> unit
public final function CopyTo(
array : Array,
index : int
)
Parameters
- array
Type: System. . :: . .Array
The one-dimensional Array that is the destination of the elements copied from the current Array.
- index
Type: System. . :: . .Int32
A 32-bit integer that represents the index in array at which copying begins.
Implements
ICollection. . :: . .CopyTo(Array, Int32)
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | array is null Nothing nullptr unit a null reference (Nothing in Visual Basic) . |
ArgumentOutOfRangeException | index is less than the lower bound of array. |
ArgumentException | array is multidimensional. -or- The number of elements in the source Array is greater than the available space 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. |
Remarks
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.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.