NameObjectCollectionBase.ICollection.CopyTo(Array, Int32) 方法
定义
从目标数组的指定索引处开始将整个 NameObjectCollectionBase 复制到兼容的一维 Array。Copies 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);
abstract member System.Collections.ICollection.CopyTo : Array * int -> unit
override this.System.Collections.ICollection.CopyTo : Array * int -> unit
Sub CopyTo (array As Array, index As Integer) Implements ICollection.CopyTo
参数
- 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.
- index
- Int32
array
中从零开始的索引,从此处开始复制。The zero-based index in array
at which copying begins.
实现
例外
array
为 null
。array
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
) 操作,其中 n
是 Count 。This method is an O(n
) operation, where n
is Count.