在.NET中,我们可以使用
<configSections>
元素来创建自定义配置节,方法如下:<configuration>
<configSections>
<section name="dictionarySample"
type="System.Configuration.DictionarySectionHandler"/>
<section name="nameValueSample"
type="System.Configuration.NameValueSectionHandler" />
</configSections>
<dictionarySample>
<add key="key1"
value="value1"/>
</dictionarySample>
<nameValueSample>
<add key="key2"
value="value2" />
</nameValueSample>
</configuration>
上面,我定义了两个部分。其中一个是类型为DictionarySectionHandler
的部分,另一个是类型为NameValueSectionHandler
的部分。
据我所知,这两个处理程序的使用方式完全相同,并且会产生相同的配置部分。
那么,它们有什么区别吗?或者说我可以交替使用它们吗?