This documentation is archived and is not being maintained.
ICollection.CopyTo Method
.NET Framework 1.1
When implemented by a class, copies the elements of the ICollection to an Array, starting at a particular Array index.
[Visual Basic] Sub CopyTo( _ ByVal array As Array, _ ByVal index As Integer _ ) [C#] void CopyTo( Array array, int index ); [C++] void CopyTo( Array* array, int index ); [JScript] function CopyTo( array : Array, index : int );
Parameters
- array
- The one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing.
- index
- The zero-based index in array at which copying begins.
Exceptions
| Exception Type | Condition |
|---|---|
| ArgumentNullException | array is a null reference (Nothing in Visual Basic). |
| ArgumentOutOfRangeException | index is less than zero. |
| ArgumentException | array is multidimensional.
-or- index is equal to or greater than the length of array. -or- The number of elements in the source ICollection is greater than the available space from index to the end of the destination array. |
| InvalidCastException | The type of the source ICollection cannot be cast automatically to the type of the destination array. |
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard
See Also
ICollection Interface | ICollection Members | System.Collections Namespace
Show: