CodeDirectiveCollection.Insert(Int32, CodeDirective) 方法

定義

將指定的 CodeDirective 物件插入集合中指定的索引。

public:
 void Insert(int index, System::CodeDom::CodeDirective ^ value);
public void Insert(int index, System.CodeDom.CodeDirective value);
member this.Insert : int * System.CodeDom.CodeDirective -> unit
Public Sub Insert (index As Integer, value As CodeDirective)

參數

index
Int32

以零為基礎的索引位置,應插入指定物件的位置。

value
CodeDirective

CodeDirective要插入的物件。

例外狀況

index 小於0。

-或-

index 大於 Count

範例

以下程式碼範例展示了如何使用該 Insert 方法在集合的索引 0 插入 CodeDirective 物件。 此範例是本類別更大 CodeDirectiveCollection 範例的一部分。

// Inserts a CodeDirective at index 0 of the collection.
collection.Insert(0, new CodeRegionDirective(CodeRegionMode.Start, "Region1"));
' Inserts a CodeDirective at index 0 of the collection.
collection.Insert(0, New CodeRegionDirective(CodeRegionMode.Start, "Region1"))

適用於