NameValueSectionHandler 和 DictionarySectionHandler 的 <add> 元素

添加自定义应用程序设置。 每个 <add> 标记都包含一个键/值对。

configuration
  <sectionName>
    <add>

语法

XML
<add key="key" value="value" />

特性

属性 说明
key 必需的特性。

指定设置的名称。
value 必需的特性。

指定设置的值。

父元素

元素 描述
<sectionName> 元素 定义使用 NameValueSectionHandlerDictionarySectionHandler 类的自定义配置节的设置。

子元素

示例

下面的示例演示如何定义自定义配置节,并使用 <add> 将设置放入该节:

XML
<configuration>
  <configSections>
    <section name="dictionarySample" type="System.Configuration.DictionarySectionHandler,System" />
  </configSections>
  <dictionarySample>
    <add key="myKey" value="myValue" />
  </dictionarySample>
</configuration>

配置文件

此元素可用于应用程序配置文件、计算机配置文件 (Machine.config) 和不在应用程序目录级别的 Web.config 文件。

请参阅