Dictionary<TKey,TValue>.KeyCollection.CopyTo(TKey[], Int32) 方法

定義

從指定的陣列索引處開始,複製 Dictionary<TKey,TValue>.KeyCollection 項目至現有一維 Array

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[]

一維 Array,是從 Dictionary<TKey,TValue>.KeyCollection 複製過來之項目的目的端。 Array 必須有以零為起始的索引。

index
Int32

array 中以零起始的索引,即開始複製的位置。

實作

例外狀況

arraynull

index 小於零。

來源 Dictionary<TKey,TValue>.KeyCollection 中的項目數大於 index 到目的 array 結尾的可用空間。

備註

元素會以逐一查看 Dictionary<TKey,TValue>.KeyCollection 的相同順序複製到 Array

這個方法是 O (n) 作業,其中 nCount

適用於

另請參閱