ジュリエットの答えは的を射ていますが、参考までに、次のよう.config
に設定することで、外部ファイルに追加の構成を配置することもできます。web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- blah blah the default stuff here -->
<!-- here, add your custom section -->
<section name="DocTabMap" type="System.Configuration.NameValueFileSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<!-- your custom section, but referenced in another file -->
<DocTabMap file="CustomDocTabs.config" />
<!-- etc, remainder of default web.config is here -->
</configuration>
次に、CustomDocTabs.config
次のようになります。
<?xml version="1.0"?>
<DocTabMap>
<add key="A" value="1" />
<add key="B" value="2" />
<add key="C" value="3" />
<add key="D" value="4" />
</DocTabMap>
これで、次のコードでアクセスできます。
NameValueCollection DocTabMap = ConfigurationManager.GetSection("DocTabMap") as NameValueCollection;
DocTabMap["A"] // == "B"