Export (0) Print
Expand All

SortedList.CopyTo Method

Copies the SortedList elements to a one-dimensional Array instance at the specified index.

[Visual Basic]
Public Overridable Sub CopyTo( _
   ByVal array As Array, _
   ByVal arrayIndex As Integer _
) Implements ICollection.CopyTo
[C#]
public virtual void CopyTo(
 Array array,
 int arrayIndex
);
[C++]
public: virtual void CopyTo(
 Array* array,
 int arrayIndex
);
[JScript]
public function CopyTo(
   array : Array,
 arrayIndex : int
);

Parameters

array
The one-dimensional Array that is the destination of the DictionaryEntry objects copied from SortedList. The Array must have zero-based indexing.
arrayIndex
The zero-based index in array at which copying begins.

Implements

ICollection.CopyTo

Exceptions

Exception Type Condition
ArgumentNullException array is a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeException arrayIndex is less than zero.
ArgumentException array is multidimensional.

-or-

arrayIndex is equal to or greater than the length of array.

-or-

The number of elements in the source SortedList is greater than the available space from arrayIndex to the end of the destination array.

InvalidCastException The type of the source SortedList cannot be cast automatically to the type of the destination array.

Remarks

The key-and-value pairs are copied to the Array in the same order in which the enumerator iterates through the SortedList.

To copy only the keys in the SortedList, use SortedList.Keys.CopyTo.

To copy only the values in the SortedList, use SortedList.Values.CopyTo.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

SortedList Class | SortedList Members | System.Collections Namespace | Array | DictionaryEntry | GetEnumerator

Show:
© 2014 Microsoft