語言

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 中的元素數量大於從 index 目的地 array到末端的可用空間。

備註

元素的複製順序與列舉子遍歷 SortedDictionary<TKey,TValue>.KeyCollection的順序相同。

此方法是一個 O(n) 運算,其中 n 為 Count。

適用於

另請參閱