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

System.Collections.ArrayList.CopyTo Method

Copies the elements from the current instance to the specified Array , starting at the specified index of the array.

public virtual void CopyTo (Array array, int arrayIndex)

Parameters

array
The one-dimensional Array that is the destination of the elements copied from the current instance. The Array.Length of this array is greater than or equal to the sum of arrayIndex and the ArrayList.Count of the current instance.
arrayIndex
A int that specifies the first index of array to which the elements of the current instance are copied. This value is greater than or equal to zero, and less than array.Length.

Exceptions

TypeReason
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionarrayIndex < 0.
ArgumentException

array has more than one dimension.

-or-

arrayIndex >= array.Length.

-or-

arrayIndex + ArrayList.Count of the current instance > array.Length.

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

Remarks

Note: This method is implemented to support the IList interface.

Operation
As described above.

This method uses Array.Copy(Array, Array, int) to copy the current instance to array.

Requirements

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