骄傲小公主

导航

C# 获取配置文件节点值

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="ManagerName" value="XXX" />
  </appSettings>
  <connectionStrings>
    <add name="DataBase" connectionString="Data Source=127.0.0.1;User ID=sa;Password=sa;Initial Catalog=test; " providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

 

string aa=ConfigurationManager.ConnectionStrings[“DataBase”].ConnectionString;//添加system.configuration引用

string bb=ConfigurationSettings.AppSettings[key].ToString();

posted on 2014-07-06 17:21  骄傲小公主  阅读(620)  评论(0编辑  收藏  举报