Collection<T>.CopyTo(T[], Int32) Método
Definição
Copia todo o Collection<T> em um Array unidimensional compatível, começando no índice especificado da matriz de destino.Copies the entire Collection<T> to a compatible one-dimensional Array, starting at the specified index of the target array.
public:
virtual void CopyTo(cli::array <T> ^ array, int index);
public void CopyTo (T[] array, int index);
abstract member CopyTo : 'T[] * int -> unit
override this.CopyTo : 'T[] * int -> unit
Public Sub CopyTo (array As T(), index As Integer)
Parâmetros
- array
- T[]
O Array unidimensional que é o destino dos elementos copiados de Collection<T>.The one-dimensional Array that is the destination of the elements copied from Collection<T>. O Array deve ter indexação com base em zero.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 zero.index
is less than zero.
O número de elementos na origem Collection<T> é maior do que o espaço disponível de index
até o final do array
de destino.The number of elements in the source Collection<T> is greater than the available space from index
to the end of the destination array
.
Comentários
Este método usa Array.Copy para copiar os elementos.This method uses Array.Copy to copy the elements.
Os elementos são copiados para o Array na mesma ordem em que o enumerador itera por meio do Collection<T> .The elements are copied to the Array in the same order in which the enumerator iterates through the Collection<T>.
Este método é uma operação O(n
), em que n
é Count.This method is an O(n
) operation, where n
is Count.