最佳答案
如何创建一个自定义 app.config 节,它只是一个简单的 add
元素列表?
我发现了一些自定义部分的例子(例如 如何在 app.config 中创建自定义配置节?) ,它们看起来像下面这样:
<RegisterCompanies>
<Companies>
<Company name="Tata Motors" code="Tata"/>
<Company name="Honda Motors" code="Honda"/>
</Companies>
</RegisterCompanies>
但是如何避免额外的集合元素(“ Companies”) ,使其看起来与 appSettings
和 connectionStrings
部分相同呢?换句话说,我想:
<registerCompanies>
<add name="Tata Motors" code="Tata"/>
<add name="Honda Motors" code="Honda"/>
</registerCompanies>