IProducerConsumerCollection<T>.CopyTo(T[], Int32) 方法

定义

从指定的索引位置开始,将 IProducerConsumerCollection<T> 的元素复制到 Array 中。Copies the elements of the IProducerConsumerCollection<T> to an Array, starting at a specified index.

public:
 void CopyTo(cli::array <T> ^ array, int index);
public void CopyTo (T[] array, int index);
abstract member CopyTo : 'T[] * int -> unit
Public Sub CopyTo (array As T(), index As Integer)

参数

array
T[]

一维 Array,它是从 IProducerConsumerCollection<T> 所复制的元素的目标位置。The one-dimensional Array that is the destination of the elements copied from the IProducerConsumerCollection<T>.

该数组的索引必须从零开始。The array must have zero-based indexing.

index
Int32

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

例外

array 为 null 引用(在 Visual Basic 中为 Nothing)。array is a null reference (Nothing in Visual Basic).

index 小于零。index is less than zero.

index 等于或大于 array 的长度 - 或 - 集合中的元素数大于从 index 到目标 array 结尾的可用空间。index is equal to or greater than the length of the array -or- The number of elements in the collection is greater than the available space from index to the end of the destination array.

注解

方法提供基础集合的快照。The method provides a snapshot of the underlying collection. 在完成复制后,其他线程可能会立即添加或移除项。It is possible for other threads to add or remove items immediately after the copy is made.

适用于