Mono Class Library: System.Collections.ICollection Overview | Members

System.Collections.ICollection.CopyTo Method

Copies the elements from the current instance to the specified Array, starting at the specified index in the array. [Edit]

public void CopyTo (Array array, int index)

Parameters

array
A one-dimensional, zero-based Array that is the destination of the elements copied from the current instance. [Edit]
index
A int that specifies the zero-based index in array at which copying begins. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionarray is null. [Edit]
ArgumentOutOfRangeExceptionindex < 0. [Edit]
ArgumentException

array has more than one dimension.

-or-

index is greater than or equal to array.Length.

-or-

The sum of index and the ICollection.Count of the current instance is greater than array.Length.

[Edit]
InvalidCastExceptionAt least one element in the current instance is not assignment-compatible with the type of array. [Edit]

Remarks

Operation
As described above.

Usage
Use this method to copy from a collection to a Array.

[Edit]

Requirements

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