NameObjectCollectionBase.ICollection.CopyTo(Array, Int32) NameObjectCollectionBase.ICollection.CopyTo(Array, Int32) Method


從目標陣列的指定索引開始,將整個 NameObjectCollectionBase 複製到相容的一維 ArrayCopies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

 virtual void System.Collections.ICollection.CopyTo(Array ^ array, int index) = System::Collections::ICollection::CopyTo;
void ICollection.CopyTo (Array array, int index);


Array Array

一維 Array,是從 NameObjectCollectionBase 複製過來之項目的目的端。The one-dimensional Array that is the destination of the elements copied from NameObjectCollectionBase. Array 必須有以零為起始的索引。The Array must have zero-based indexing.

Int32 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- 來源 NameObjectCollectionBase 中的項目數大於 index 到目的 array 結尾的可用空間。The number of elements in the source NameObjectCollectionBase is greater than the available space from index to the end of the destination array.

來源 NameObjectCollectionBase 的類型無法自動轉換成目的 array 的類型。The type of the source NameObjectCollectionBase cannot be cast automatically to the type of the destination array.


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

這個方法會使用Array.Copy複製項目。This method uses Array.Copy to copy the elements.

雖然ICollection.CopyTo方法不是預設的情況下,COM 用戶端看見繼承NameObjectCollectionBase類別將它公開,並在 COM 用戶端可能會導致非預期的行為。While the ICollection.CopyTo method is not visible to COM clients by default, inheriting the NameObjectCollectionBase class can expose it and can cause undesirable behavior in COM clients.

這個方法是 O (n) 運算,其中nCountThis method is an O(n) operation, where n is Count.