SortedDictionary<TKey,TValue>.CopyTo(KeyValuePair<TKey,TValue>[], Int32) Método

Definição

Copia os elementos da SortedDictionary<TKey,TValue> para a matriz especificada de estruturas KeyValuePair<TKey,TValue>, começando no índice especificado.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)

Parâmetros

array
KeyValuePair<TKey,TValue>[]

A matriz unidimensional das estruturas KeyValuePair<TKey,TValue> que é o destino dos elementos copiados da SortedDictionary<TKey,TValue> atual. A matriz deve ter indexação baseada em zero.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

O índice com base em zero em array no qual a cópia começa.The zero-based index in array at which copying begins.

Implementações

Exceções

array é null.array is null.

index é menor que 0.index is less than 0.

O número de elementos na origem SortedDictionary<TKey,TValue> é maior do que o espaço disponível de index até o final do array de destino.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.

Comentários

Observação

Se o tipo da origem SortedDictionary<TKey,TValue> não puder ser convertido automaticamente no tipo do destino array , as implementações não genéricas de ICollection.CopyTo throw InvalidCastException , enquanto as implementações genéricas serão lançadas ArgumentException .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.

Este método é uma operação O(n), em que n é Count.This method is an O(n) operation, where n is Count.

Aplica-se a