大家好!我有一個疑惑,就是我新建一個.NET Framework類別庫工程,然后新添加一個應用程式組態檔App.config,在App.config添加內容:
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="dbSql" value="https://bbs.csdn.net/topics/Data source=SQLEXPRESS;initial catalog=guangxio1;user id=sa;password=guest"/>
</appSettings>
</configuration>
然后在撰寫C#代碼,在代碼中就能這樣獲取App.config中的內容:
string strConnect = ConfigurationManager.AppSettings["dbSql"];
我比較疑惑的一點是ConfigurationManager這個物件是如何找到App.config,它倆是如何關聯上的呢?再假設我再添加一個應用程式組態檔,它怎么區分找哪個應用程式組態檔呢?我找遍工程屬性,也沒找到它倆怎么關聯起來的證據。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/106159.html
上一篇:c# BitMap GetHbitmap()耗時很高有沒有什么辦法
下一篇:sql插入日期語法錯誤
