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

Adds a configuration element to the ConfigurationElementCollection.

protected virtual void BaseAdd (System.Configuration.ConfigurationElement element);

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.
}

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

.NET 9 (package-provided) en andere versies
Product Versies
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

BaseAdd(ConfigurationElement, Boolean)

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

Adds a configuration element to the configuration element collection.

protected internal void BaseAdd (System.Configuration.ConfigurationElement element, bool throwIfExists);
protected void BaseAdd (System.Configuration.ConfigurationElement element, bool throwIfExists);

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

.NET 9 (package-provided) en andere versies
Product Versies
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

BaseAdd(Int32, ConfigurationElement)

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);

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

.NET 9 (package-provided) en andere versies
Product Versies
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9