最简单的,key-value类型:

1 <configuration>
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;  //NameValueCollection 
2 
3 NameValueCollection collection = ConfigurationManager.GetSection("ServerTableNames"as NameValueCollection;
4 string serverTableName = collection[serverType.ToString()];


参考:

在web.config或app.config中增加自定义配置方法大全 

Web.config中的自定义配置节

相关文章:

  • 2021-12-02
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-08-25
猜你喜欢
  • 2022-02-14
  • 2021-09-09
  • 2021-07-05
  • 2022-12-23
  • 2022-01-15
相关资源
相似解决方案