CodeStatementCollection.CopyTo(CodeStatement[], Int32) 方法

定义

从指定的索引处开始,将对象的元素 CodeStatementCollection 复制到一维 Array 实例。

public:
 void CopyTo(cli::array <System::CodeDom::CodeStatement ^> ^ array, int index);
public void CopyTo(System.CodeDom.CodeStatement[] array, int index);
member this.CopyTo : System.CodeDom.CodeStatement[] * int -> unit
Public Sub CopyTo (array As CodeStatement(), index As Integer)

参数

array
CodeStatement[]

一维 Array 是从集合复制的值的目标。

index
Int32

开始插入的数组的索引。

例外

目标数组是多维数组。

-或-

中的 CodeStatementCollection 元素数大于由参数指定的 index 目标数组的索引与目标数组末尾之间的可用空间。

参数 arraynull.

参数 index 小于目标数组的最小索引。

示例

下面的示例演示如何从指定的索引值开始,将对象的内容 CodeStatementCollection 复制到数组。

// Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
// 'statements' is a CodeStatement array.
CodeStatement[] statementArray = new CodeStatement[collection.Count];
collection.CopyTo( statementArray, 0 );
' Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
' 'statements' is a CodeStatement array.
Dim statementArray(collection.Count - 1) As CodeStatement
collection.CopyTo(statementArray, 0)

适用于

另请参阅