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

定义

从指定数组索引开始将 Dictionary<TKey,TValue>.ValueCollection 元素复制到现有一维 Array 中。Copies the Dictionary<TKey,TValue>.ValueCollection elements to an existing one-dimensional Array, starting at the specified array index.

public:
 virtual void CopyTo(cli::array <TValue> ^ array, int index);
public void CopyTo (TValue[] array, int index);
abstract member CopyTo : 'Value[] * int -> unit
override this.CopyTo : 'Value[] * int -> unit
Public Sub CopyTo (array As TValue(), index As Integer)

参数

array
TValue[]

一维 Array,它是从 Dictionary<TKey,TValue>.ValueCollection 复制的元素的目标。The one-dimensional Array that is the destination of the elements copied from Dictionary<TKey,TValue>.ValueCollection. Array 必须具有从零开始的索引。The Array must have zero-based indexing.

index
Int32

array 中从零开始的索引,从此处开始复制。The zero-based index in array at which copying begins.

实现

例外

arraynullarray is null.

index 小于零。index is less than zero.

Dictionary<TKey,TValue>.ValueCollection 中的元素个数大于从 index 到目标 array 末尾之间的可用空间。The number of elements in the source Dictionary<TKey,TValue>.ValueCollection is greater than the available space from index to the end of the destination array.

注解

元素 Array 按枚举器循环访问的相同顺序复制到中 Dictionary<TKey,TValue>.ValueCollectionThe elements are copied to the Array in the same order in which the enumerator iterates through the Dictionary<TKey,TValue>.ValueCollection.

此方法是 O (n) 操作,其中 nCountThis method is an O(n) operation, where n is Count.

适用于

另请参阅