语言

SortedDictionary<TKey,TValue>.KeyCollection.CopyTo 方法

定义

从指定的数组索引开始,将 SortedDictionary<TKey,TValue>.KeyCollection 元素复制到现有的一维数组。

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)

参数

array
TKey[]

一维数组,它是从中 SortedDictionary<TKey,TValue>.KeyCollection复制的元素的目标。 数组必须具有从零开始的索引。

index
Int32

从零开始复制的索引 array 。

实现

例外

array 是 null。

index 小于 0。

源SortedDictionary<TKey,TValue>.KeyCollection中的元素数大于目标indexarray末尾的可用空间。

注解

元素按枚举器循环访问 SortedDictionary<TKey,TValue>.KeyCollection数组的顺序复制到数组。

此方法是 O(n) 操作,其中 n 。Count

适用于

另请参阅