SortedDictionary<TKey, TValue>.CopyTo Method

Copies the elements of the SortedDictionary<TKey, TValue> to the specified array of KeyValuePair<TKey, TValue> structures, starting at the specified index.

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

public void CopyTo(
	KeyValuePair<TKey, TValue>[] array,
	int index
)

Parameters

array
Type: System.Collections.Generic.KeyValuePair<TKey, TValue>[]

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
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 0.

ArgumentException

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.

NoteNote

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.

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

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft