我已经定义:加载数据,并连接到属性
public static string Firstname { get; set; }
public static string Surname { get; set; }
public static bool DocBook5 { get; set; }
public static string Language { get; set; }
我存储在App.config该信息。
然后我用的是装载并连接:
Firstname = ConfigurationManager.AppSettings["firstname"];
Surname = ConfigurationManager.AppSettings["surname"];
DocBook5 = Convert.ToBoolean(ConfigurationManager.AppSettings["docbook5"]);
Language = ConfigurationManager.AppSettings["language"];
但是,如果我只是给出一些属性内容为Console.WriteLine,它看起来像属性为空。 GetConfig类的完整代码可以显示there
也许有人知道为什么?
您可以分享您的app.config吗?你的项目是一个控制台应用程序或网络? –
也可以告诉我为什么你需要静态属性? –
您的密钥位于下的节点不在AppSetting下。并且您的代码正在从appsetting部分读取。所以你得到空白结果 –