Foley .NET Utilities Class Library

Collection2Base.CopyTo Method 

Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.

[Visual Basic]
Overridable Public Sub CopyTo( _
   ByVal array As Array, _
   ByVal index As Integer _
) Implements _
   ICollection.CopyTo
[C#]
public virtual void CopyTo(
   Array array,
   int index
);

Parameters

array
The one-dimensional Array that is the destination of the elementscopied from the collection. The Array must have zero-based indexing.
index
The zero-based index in array at which copying begins.

Implements

ICollection.CopyTo

Exceptions

Exception TypeCondition
System.ArgumentNullException The array is a null reference (Nothing in Visual Basic).
System.ArgumentOutOfRangeException The index is less than zero.
System.ArgumentException

The array is multidimensional.

-or-

The index is equal to or greater than the length of array.

-or-

The number of elements in the collection is greater than the available space from index to the end of the destination array.

See Also

Collection2Base Class | Collection2Base Members | Foley.Utilities.Collections Namespace