Share via


CodeDirectiveCollection.CopyTo(CodeDirective[], Int32) 方法

定義

複製集合的內容至指定索引開頭的一維陣列。

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

參數

array
CodeDirective[]

型別為 CodeDirective 的陣列,其是從集合複製之值的目的端。

index
Int32

要開始插入集合物件的陣列索引。

例外狀況

目的端陣列為多維。

-或-

CodeDirectiveCollection 中的項目數,大於 index 指定的目標陣列索引與目標陣列結尾之間的可用空間。

arraynull

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

範例

下列程式代碼範例示範如何使用 CopyTo 方法來將集合的內容從索引 0 開始複製到指定的 CodeDirective 數位列。 此範例是針對 類別提供的較大範例的 CodeDirectiveCollection 一部分。

// Copies the contents of the collection beginning at index 0 to the specified CodeDirective array.
// 'directives' is a CodeDirective array.
collection.CopyTo(directives, 0);
' Copies the contents of the collection beginning at index 0 to the specified CodeDirective array.
' 'directives' is a CodeDirective array.
collection.CopyTo(directives, 0)

適用於