語言

CustomErrorCollection.RemoveAt(Int32) 方法

定義

從集合中移除指定索引位置的 CustomError 物件。

public:
 void RemoveAt(int index);
public void RemoveAt(int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

參數

index
Int32

要移除物件的 CustomError 集合索引。

範例

以下程式碼範例說明如何在指定索引處移除 CustomError 物件。 參考課堂主題中的 CustomErrorCollection 程式碼範例,學習如何取得該集合。

// Using method RemoveAt.
if (!customErrorsSection.SectionInformation.IsLocked)
{
    // Remove the error at 0 index
    customErrorsCollection.RemoveAt(0);
    configuration.Save();
}
' Using method RemoveAt.
If Not customErrorsSection.SectionInformation.IsLocked Then
   ' Remove the error at 0 index
   customErrorsCollection.RemoveAt(0)
   configuration.Save()
End If

備註

此 RemoveAt 方法會在配置檔的當前階層層級插入一個 remove 元素 customErrors 。 這是為了移除階層 add 結構中父組態檔案中定義的元素參考。

註add這些元素不會從父組態檔案中刪除。 它們只是被停用。 然而,這個 RemoveAt 方法實際上會在目前的階層層級刪除它們。

適用於