码迷,mamicode.com
首页 > 移动开发 > 详细

ASP.NET、WinForm、C# - 配置文件信息读取 [ Web.config || Appconfig ]

时间:2015-07-06 19:29:55      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

<configuration>
  
    <appSettings>
      <add key="name" value="HF_Ultrastrong"/>
    </appSettings>
  
    <connectionStrings>
      <add name="ConString" connectionString="server = ***; DATABASE = DB_News; integrated security = true"/>
    </connectionStrings>
  
</configuration>

 

 

获取配置文件中<appSettings>或是<connectionStrings>的值:

 

<appSettings>

//方法1
string Name = ConfigurationManager.AppSettings["name"].ToString();
//方法2
string Name = ConfigurationManager.AppSettings["name"];

 

<connectionStrings>

string ConString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;

 

ASP.NET、WinForm、C# - 配置文件信息读取 [ Web.config || Appconfig ]

标签:

原文地址:http://www.cnblogs.com/KTblog/p/4625042.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!