Modifica

Condividi tramite


ConfigurationElementCollection.BaseAdd Method

Definition

Adds a ConfigurationElement to an ConfigurationElementCollection instance when overridden in a derived class.

Overloads

BaseAdd(ConfigurationElement)

Adds a configuration element to the ConfigurationElementCollection.

BaseAdd(ConfigurationElement, Boolean)

Adds a configuration element to the configuration element collection.

BaseAdd(Int32, ConfigurationElement)

Adds a configuration element to the configuration element collection.

Remarks

Use the BaseAdd method to add a new ConfigurationElement to the collection. Override in a derived class if custom behavior is required when the element is added.

When adding, an element is considered a duplicate only if the keys are identical but the values are different. Elements with identical keys and values are accepted silently because the elements do not compete. However, an element with an identical key but a different value cannot be added because there is no logic to determine which of the competing values should be honored.

BaseAdd(ConfigurationElement)

Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs

Adds a configuration element to the 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)

Parameters

Examples

The following code example shows how to override the BaseAdd method and how to call it from an Add method.

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

Remarks

Use the BaseAdd method to add a new ConfigurationElement to the collection. Override it in a derived class if custom behavior is required when the element is added.

When adding, an element is considered a duplicate only if the keys are identical but the values are different. Elements with identical keys and values are accepted silently because the elements do not compete. However, an element with an identical key but a different value cannot be added because there is no logic to determine which of the competing values should be honored.

Applies to

BaseAdd(ConfigurationElement, Boolean)

Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs

Adds a configuration element to the configuration element collection.

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);
protected void BaseAdd (System.Configuration.ConfigurationElement element, bool throwIfExists);
member this.BaseAdd : System.Configuration.ConfigurationElement * bool -> unit
Protected Friend Sub BaseAdd (element As ConfigurationElement, throwIfExists As Boolean)
Protected Sub BaseAdd (element As ConfigurationElement, throwIfExists As Boolean)

Parameters

throwIfExists
Boolean

true to throw an exception if the ConfigurationElement specified is already contained in the ConfigurationElementCollection; otherwise, false.

Exceptions

The ConfigurationElement to add already exists in the ConfigurationElementCollection and the throwIfExists parameter is true.

Remarks

Use the optional parameter throwIfExists to throw an Exception exception if the specified ConfigurationElement object already exists in the ConfigurationElementCollection collection.

An element is considered a duplicate only if the keys are identical but the values are different. Elements with identical keys and values are accepted silently because the elements do not compete. However, an element with an identical key but a different value cannot be added because there is no logic to determine which of the competing values should be honored.

Applies to

BaseAdd(Int32, ConfigurationElement)

Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs
Source:
ConfigurationElementCollection.cs

Adds a configuration element to the configuration element collection.

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)

Parameters

index
Int32

The index location at which to add the specified ConfigurationElement.

Remarks

Use the index parameter to add the ConfigurationElement object to the ConfigurationElementCollection at a specific index location.

Applies to