ConfigurationElementCollection.BaseAdd Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds a ConfigurationElement to an ConfigurationElementCollection instance when overridden in a derived class.
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. |
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.
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
- element
- ConfigurationElement
The ConfigurationElement to add.
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
.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 |
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
- element
- ConfigurationElement
The ConfigurationElement to add.
- 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 |
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.
- element
- ConfigurationElement
The ConfigurationElement to add.
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 |
Feedback over .NET
.NET is een opensourceproject. Selecteer een koppeling om feedback te geven: