Rediger

Del via


Dictionary<TKey,TValue>.KeyCollection.CopyTo(TKey[], Int32) Method

Definition

Copies the Dictionary<TKey,TValue>.KeyCollection elements to an existing one-dimensional Array, starting at the specified array index.

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

Parameters

array
TKey[]

The one-dimensional Array that is the destination of the elements copied from Dictionary<TKey,TValue>.KeyCollection. 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 zero.

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

Remarks

The elements are copied to the Array in the same order in which the enumerator iterates through the Dictionary<TKey,TValue>.KeyCollection.

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

Applies to

See also