<remove> Element for NameValueSectionHandler and DictionarySectionHandler
Removes a previously defined setting.
<configuration>
** <sectionName>**
** <remove>**
<remove key="predefened setting key"/>
Required Attributes
Attribute | Description |
---|---|
key | Specifies the key name of the setting to remove. |
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" />
</sectionGroup>
</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
Configuration Sections Schema | Configuration Section Settings