ConfigurationManager.AppSettings计数0 [英] ConfigurationManager.AppSettings count 0

查看:71
本文介绍了ConfigurationManager.AppSettings计数0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#-ConfigurationManager.AppSettings计数为0.这是代码:

C# - ConfigurationManager.AppSettings count is 0. And ideas? Here is the code:

  var appSettings = ConfigurationManager.AppSettings;

                    if (appSettings.Count == 0)
                    {
                        Console.WriteLine("AppSettings is empty.");
                    }

在调试中运行.VS将app.config复制到调试目录并命名CBCuedERI.exe.config.这是配置文件的一部分

Running in debug. VS copies the app.config to the debug directory and names it CBCuedERI.exe.config. Here is part of the config file

<applicationSettings>
    <CBCuedERI.Properties.Settings>
        <setting name="test" serializeAs="String">
            <value>one</value>
        </setting>
    </CBCuedERI.Properties.Settings>
</applicationSettings>

我也试过了,它返回NULL

I also tried this and it returns NULL

  string sss = ConfigurationManager.AppSettings.Get ( "test") ;

推荐答案

ConfigurationManager.AppSettings用于appSettings部分中的键值对

ConfigurationManager.AppSettings is used for the key value pairs in appSettings section

从app.config或网络中读取设置..net中的配置

这篇关于ConfigurationManager.AppSettings计数0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆