CodeStatementCollection.CopyTo(CodeStatement[], Int32) Metod

Definition

Kopierar elementen i CodeStatementCollection objektet till en endimensionell Array instans med början vid det angivna indexet.

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)

Parametrar

array
CodeStatement[]

Den endimensionella Array som är målet för de värden som kopieras från samlingen.

index
Int32

Indexet för matrisen som ska börja infogas.

Undantag

Målmatrisen är flerdimensionell.

-eller-

Antalet element i CodeStatementCollection är större än det tillgängliga utrymmet mellan indexet för målmatrisen som anges av parametern index och slutet av målmatrisen.

Parametern array är null.

Parametern index är mindre än målmatrisens minsta index.

Exempel

I följande exempel visas hur du kopierar innehållet i ett CodeStatementCollection objekt till en matris, med början vid det angivna indexvärdet.

// 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)

Gäller för

Se även