StateManagedCollection.CopyTo(Array, Int32) 方法

定義

從特定的陣列索引開始,將 StateManagedCollection 集合的項目複製到陣列。Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index.

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
Public Sub CopyTo (array As Array, index As Integer)

參數

array
Array

一維 Array,是從 StateManagedCollection 複製過來的項目之目的端。The one-dimensional Array that is the destination of the elements copied from the StateManagedCollection. 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.

array 是多維的。array is multidimensional.

-或--or- index 大於或等於 array 的長度。index is greater than or equal to the length of array.

-或--or- 來源 StateManagedCollection 中的項目數大於從 index 到目的 array 結尾的可用空間。The number of elements in the source StateManagedCollection is greater than the available space from the index to the end of the destination array.

備註

指定的陣列必須是相容的類型。The specified array must be of a compatible type.

這些元素會以列舉值逐一查看 Array 集合的相同順序複製到 StateManagedCollectionThe elements are copied to the Array in the same order in which the enumerator iterates through the StateManagedCollection collection.

適用於