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

Definition

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

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

Parameters

array
TValue[]

The one-dimensional Array that is the destination of the elements copied from Dictionary<TKey,TValue>.ValueCollection. The Array must have zero-based indexing.

index
Int32

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

Exceptions

array is null.

index is less than zero.

The number of elements in the source Dictionary<TKey,TValue>.ValueCollection 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>.ValueCollection.

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

Applies to

See also