Export (0) Print
Expand All

Dictionary<TKey, TValue>.KeyCollection.CopyTo Method

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

Namespace:  System.Collections.Generic
Assemblies:   System.Collections (in System.Collections.dll)
  mscorlib (in mscorlib.dll)

public void CopyTo(
	TKey[] array,
	int index
)

Parameters

array
Type: 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
Type: System.Int32

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

Implements

ICollection<T>.CopyTo(T[], Int32)

ExceptionCondition
ArgumentNullException

array is null.

ArgumentOutOfRangeException

index is less than zero.

ArgumentException

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.

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft