Muokkaa

Jaa


SortedDictionary<TKey,TValue>.CopyTo Method

Definition

Copies the elements of the SortedDictionary<TKey,TValue> to the specified array of KeyValuePair<TKey,TValue> structures, starting at the specified index.

public:
 virtual void CopyTo(cli::array <System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ array, int index);
public void CopyTo (System.Collections.Generic.KeyValuePair<TKey,TValue>[] array, int index);
abstract member CopyTo : System.Collections.Generic.KeyValuePair<'Key, 'Value>[] * int -> unit
override this.CopyTo : System.Collections.Generic.KeyValuePair<'Key, 'Value>[] * int -> unit
Public Sub CopyTo (array As KeyValuePair(Of TKey, TValue)(), index As Integer)

Parameters

array
KeyValuePair<TKey,TValue>[]

The one-dimensional array of KeyValuePair<TKey,TValue> structures that is the destination of the elements copied from the current SortedDictionary<TKey,TValue> The array must have zero-based indexing.

index
Int32

The zero-based index in array at which copying begins.

Implements

Exceptions

array is null.

index is less than 0.

The number of elements in the source SortedDictionary<TKey,TValue> is greater than the available space from index to the end of the destination array.

Remarks

Note

If the type of the source SortedDictionary<TKey,TValue> cannot be cast automatically to the type of the destination array, the nongeneric implementations of ICollection.CopyTo throw InvalidCastException, whereas the generic implementations throw ArgumentException.

This method is an O(n) operation, where n is Count.

Applies to