解释:
System.Configuration.ConfigurationManager.AppSettings["DB"]
b/s程序
从web.config配置文件中获取key值为"DB"的Value
c/s程序
从app.config配置文件中获取key值为"DB"的Value
作用:
<AppSettings>
<add key="config1" value="a" />
<add key="config2" value="b" />
</AppSettings>
string str = System.Configuration.ConfigurationManager.AppSettings[“config1”].ToString();
//str等于a
string str1 = System.Configuration.ConfigurationManager.AppSettings[“config2”].ToString();
//str1等于b
本文详细介绍了如何在b/s和c/s程序中使用System.Configuration.ConfigurationManager.AppSettings从web.config和app.config配置文件中读取特定键的值。通过实例演示了如何获取AppSettings中的配置项,并将其转换为字符串。
3631





