在web.config中添加简单的自定义段
时间:2010-10-05 来源:lbsx
最简单的,key-value类型:
2 <configSections>
3 <section name="KeyValueSection" type="System.Configuration.NameValueSectionHandler"/>
4 </configSections>
5 <KeyValueSection>
6 <add key="0" value="v0"/>
7 <add key="1" value="v1"/>
8 </KeyValueSection>
9 </configuration>
在代码中获取值:
1 using System.Collections.Specialized; //NameValueCollection2
3 NameValueCollection collection = ConfigurationManager.GetSection("ServerTableNames") as NameValueCollection;
4 string serverTableName = collection[serverType.ToString()];
参考:
在web.config或app.config中增加自定义配置方法大全
Web.config中的自定义配置节
相关阅读 更多 +