ReadOnlyCollection<T>.ICollection.CopyTo(Array, Int32) ReadOnlyCollection<T>.ICollection.CopyTo(Array, Int32) Method

定義

從特定的 ICollection 索引開始,將 Array 的項目複製到 ArrayCopies the elements of the ICollection to an Array, starting at a particular Array index.

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

參數

array
Array Array

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

index
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- array 沒有以零起始的索引。array does not have zero-based indexing.

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

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

備註

注意

如果ICollection來源的型別無法自動轉換成目的地array的型別, 就會ICollection.CopyToInvalidCastException回的非泛型實作為, 而泛型的執行則會ArgumentException擲回。If the type of the source ICollection cannot be cast automatically to the type of the destination array, the non-generic implementations of ICollection.CopyTo throw InvalidCastException, whereas the generic implementations throw ArgumentException.

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

這個成員是明確介面成員實作,This member is an explicit interface member implementation. 只有在 ReadOnlyCollection<T> 執行個體轉換成 ICollection 介面時,才能使用這個成員。It can be used only when the ReadOnlyCollection<T> instance is cast to an ICollection interface.

適用於