ConfigurationElementCollection.BaseAdd 方法

定義

在衍生類別中覆寫時,將 ConfigurationElement 加入 ConfigurationElementCollection 執行個體。

多載

BaseAdd(ConfigurationElement)

將組態項目新增至 ConfigurationElementCollection

BaseAdd(ConfigurationElement, Boolean)

將組態項目加入組態項目集合。

BaseAdd(Int32, ConfigurationElement)

將組態項目加入組態項目集合。

備註

BaseAdd使用方法,將新的 ConfigurationElement 加入至集合。 如果新增專案時需要自訂行為,請在衍生類別中覆寫 。

新增項目時,只有在索引鍵完全相同而值不同時,才會將項目視為重複。 索引鍵和值都完全相同的項目是以無訊息模式接受,因為項目不會競爭。 但是不能新增具有完全相同索引鍵而不同值的項目,因為沒有邏輯可決定在兩個競爭的值當中應該接受哪一個。

BaseAdd(ConfigurationElement)

來源:
ConfigurationElementCollection.cs
來源:
ConfigurationElementCollection.cs
來源:
ConfigurationElementCollection.cs

將組態項目新增至 ConfigurationElementCollection

protected:
 virtual void BaseAdd(System::Configuration::ConfigurationElement ^ element);
protected virtual void BaseAdd (System.Configuration.ConfigurationElement element);
abstract member BaseAdd : System.Configuration.ConfigurationElement -> unit
override this.BaseAdd : System.Configuration.ConfigurationElement -> unit
Protected Overridable Sub BaseAdd (element As ConfigurationElement)

參數

element
ConfigurationElement

要加入的 ConfigurationElement

範例

下列程式代碼範例示範如何覆寫 BaseAdd 方法,以及如何從 Add 方法呼叫方法。

public void Add(UrlConfigElement url)
{
    BaseAdd(url);

    // Your custom code goes here.
}
Public Sub Add(ByVal url As UrlConfigElement)
    BaseAdd(url)

    ' Your custom code goes here.

End Sub

備註

BaseAdd使用方法,將新的 ConfigurationElement 加入至集合。 如果新增專案時需要自定義行為,請在衍生類別中覆寫它。

新增項目時,只有在索引鍵完全相同而值不同時,才會將項目視為重複。 索引鍵和值都完全相同的項目是以無訊息模式接受,因為項目不會競爭。 但是不能新增具有完全相同索引鍵而不同值的項目,因為沒有邏輯可決定在兩個競爭的值當中應該接受哪一個。

適用於

BaseAdd(ConfigurationElement, Boolean)

來源:
ConfigurationElementCollection.cs
來源:
ConfigurationElementCollection.cs
來源:
ConfigurationElementCollection.cs

將組態項目加入組態項目集合。

protected:
 void BaseAdd(System::Configuration::ConfigurationElement ^ element, bool throwIfExists);
protected public:
 void BaseAdd(System::Configuration::ConfigurationElement ^ element, bool throwIfExists);
protected void BaseAdd (System.Configuration.ConfigurationElement element, bool throwIfExists);
protected internal void BaseAdd (System.Configuration.ConfigurationElement element, bool throwIfExists);
member this.BaseAdd : System.Configuration.ConfigurationElement * bool -> unit
Protected Sub BaseAdd (element As ConfigurationElement, throwIfExists As Boolean)
Protected Friend Sub BaseAdd (element As ConfigurationElement, throwIfExists As Boolean)

參數

element
ConfigurationElement

要加入的 ConfigurationElement

throwIfExists
Boolean

true 表示如果指定的 ConfigurationElement 已經包含於 ConfigurationElementCollection,則擲回例外狀況,否則為 false

例外狀況

要加入的 ConfigurationElement 已存在於 ConfigurationElementCollection,且 throwIfExists 參數為 true

備註

如果指定的ConfigurationElement物件已存在於集合中,請使用選擇性參數throwIfExists擲回Exception例外狀況ConfigurationElementCollection

只有在索引鍵相同但值不同時,才會將元素視為重複專案。 索引鍵和值都完全相同的項目是以無訊息模式接受,因為項目不會競爭。 但是不能新增具有完全相同索引鍵而不同值的項目,因為沒有邏輯可決定在兩個競爭的值當中應該接受哪一個。

適用於

BaseAdd(Int32, ConfigurationElement)

來源:
ConfigurationElementCollection.cs
來源:
ConfigurationElementCollection.cs
來源:
ConfigurationElementCollection.cs

將組態項目加入組態項目集合。

protected:
 virtual void BaseAdd(int index, System::Configuration::ConfigurationElement ^ element);
protected virtual void BaseAdd (int index, System.Configuration.ConfigurationElement element);
abstract member BaseAdd : int * System.Configuration.ConfigurationElement -> unit
override this.BaseAdd : int * System.Configuration.ConfigurationElement -> unit
Protected Overridable Sub BaseAdd (index As Integer, element As ConfigurationElement)

參數

index
Int32

要加入指定 ConfigurationElement 的索引位置。

element
ConfigurationElement

要加入的 ConfigurationElement

備註

index使用 參數,將 ConfigurationElement 物件加入至ConfigurationElementCollection特定索引位置的 。

適用於