ParserErrorCollection.Insert(Int32, ParserError) 方法

定義

將指定的 ParserError 物件插入至集合中所指定索引處。

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

參數

index
Int32

集合中要插入 ParserError 的索引處。

value
ParserError

要插入集合的 ParserError 物件。

範例

下列程式碼範例示範如何在集合中指定的索引 ParserErrorCollection 處插入 ParserError 物件。

// Insert a ParserError at index 0 of the collection.
ParserError error = new ParserError("Error", "Path", 1);
collection.Insert(0, error);

// Remove the specified ParserError from the collection.
collection.Remove(error);
' Insert a ParserError at index 0 of the collection.
Dim [error] As New ParserError("Error", "Path", 1)
collection.Insert(0, [error])

' Remove the specified ParserError from the collection.
collection.Remove([error])

備註

使用 方法, Insert 在集合內的特定索引處插入現有的 ParserError 物件。

您無法多次將相同的 ParserError 物件新增至集合。 當您使用 ParserError 已經在集合中的 呼叫 Insert 方法時,插入會失敗。 在插入之前使用 Contains 方法,判斷特定 ParserError 是否已經在集合中。 若要在集合中重新置放 ParserError ,您必須先使用 Remove 方法將其移除,然後使用 將它插入所需的索引 Insert 處。

適用於