ArrangedElementCollection.CopyTo(Array, Int32) 方法

定义

从目标数组的指定索引处开始将此集合的全部内容复制到兼容的一维 ArrayCopies the entire contents of this collection to a compatible one-dimensional Array, starting at the specified index of the target array.

public:
 virtual void CopyTo(Array ^ array, int index);
public void CopyTo (Array array, int index);
abstract member CopyTo : Array * int -> unit
override this.CopyTo : Array * int -> unit

参数

array
Array

一维 Array,用作从当前集合复制的元素的目标数组。The one-dimensional Array that is the destination of the elements copied from the current collection. 该数组的索引必须从零开始。The array must have zero-based indexing.

index
Int32

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

实现

异常

arraynullarray is null.

index 小于 0。index is less than 0.

array 是多维的。array is multidimensional.

-or- 源集合中的元素数目大于从 indexarray 末尾的可用空间。The number of elements in the source collection is greater than the available space from index to the end of array.

源元素的类型不能自动强制转换为 array 类型。The type of the source element cannot be cast automatically to the type of array.

注解

指定数组的类型必须与源集合兼容。The type of the specified array must be compatible with the source collection.

此方法使用Array.Copy方法复制元素。This method uses the Array.Copy method to copy the elements.

适用于

另请参阅