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

System.Collections.ArrayList.CopyTo Method

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

public virtual void CopyTo (int index, Array array, int arrayIndex, int count)

Parameters

index
A int that specifies the index in the current instance at which copying begins. This value is greater than or equal to 0, and less than the ArrayList.Count of the current instance.
array
The one-dimensional Array that is the destination of the elements copied from 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 minus count.
count
A int that specifies the number of elements to copy. This value is greater than or equal to 0, and less than both the ArrayList.Count of the current instance minus index and array.Length minus arrayIndex.

Exceptions

TypeReason
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeException

index < 0.

-or-

arrayIndex < 0.

-or-

count < 0.

ArgumentException

array has more than one dimension.

-or-

index >= ArrayList.Count of the current instance .

-or-

count >= ArrayList.Count of the current instance - index.

-or-

count >= array.Length - arrayIndex.

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

Remarks

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