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 參數指定的目標陣列索引和目標陣列結尾之間的可用空間。

array 參數為 null

index 參數小於目標陣列的最小索引。

範例

下列範例示範如何從指定的索引值開始,將對象的內容 CodeStatementCollection 複製到陣列。

// Copies the contents of the collection beginning at index 0 to the specified CodeStatement array.
// 'statements' is a CodeStatement array.
collection->CopyTo( statements, 0 );
// 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)

適用於

另請參閱