語言

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 。

實作

例外狀況

array 是 null。

index 小於零。

來源 Dictionary<TKey,TValue>.KeyCollection 中的元素數量大於從 index 目的地 array到末端的可用空間。

備註

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

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

適用於

另請參閱