Edit

Share via


<remove> element for NameValueSectionHandler and DictionarySectionHandler

Removes a previously defined setting.

<configuration>
  <sectionName>
    <remove>

Syntax

<add remove="key" />

Attribute

Description
key Required attribute.

Specifies the name of the setting to remove.

Parent element

Element Description
<sectionName> Element Defines settings for custom configuration sections that use the NameValueSectionHandler and DictionarySectionHandler classes.

Child elements

None

Remarks

You can use the <remove> element to remove settings from your application that were defined at a higher level in the configuration file hierarchy.

Example

The following example shows how to use the <remove> element in an application configuration file to remove settings previously defined in the machine configuration file.

The following machine configuration file code declares the section <mySection> and adds two settings, key1 and key2, to it:

<!-- Machine.config file -->
<configuration>
  <configSections>
    <section name="mySection" type="System.Configuration.NameValueSectionHandler,System" />
  </configSections>
  <mySection>
    <add key="key1" value="value1" />
    <add key="key2" value="value2" />
  </mySection>
</configuration>

The following application configuration file code removes the key2 setting from <mySection>:

<!--Application configuration file -->
<configuration>
  <mySection>
    <remove key="key2" />
  </mySection>
</configuration>

Configuration file

This element can be used in the application configuration file, machine configuration file (Machine.config), and Web.config files that are not at the application directory level.

See also