CodeStatementCollection.CopyTo(CodeStatement[], Int32) メソッド

定義

CodeStatementCollection オブジェクトの要素を、指定したインデックスから始まる 1 次元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[]

コレクションからコピーされた値のコピー先となる 1 次元 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.
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)

適用対象

こちらもご覧ください