检索的app.config文件中的设置名称 [英] Retrieve name of the Setting from app.config file

查看:186
本文介绍了检索的app.config文件中的设置名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检索的app.config文件的密钥设置的名称。

I need to retrieve the name of the key setting from app.config file.

例如:

我的app.config文件:

My app.config file:

<setting name="IGNORE_CASE" serializeAs="String">
    <value>False</value>
</setting>

我知道我可以使用检索值:

I know i can retrieve the value using:

Properties.Settings.Default.IGNORE_CASE

有没有办法从我的键设置得到字符串IGNORE_CASE?

Is there a way to get the string "IGNORE_CASE" from my key setting ?

推荐答案

试试这个:

System.Collections.IEnumerator enumerator = Properties.Settings.Default.Properties.GetEnumerator();

while (enumerator.MoveNext())
{
    Debug.WriteLine(((System.Configuration.SettingsProperty)enumerator.Current).Name);
}

编辑:用foreach方法的建议

with foreach approach as suggested

foreach (System.Configuration.SettingsProperty property in Properties.Settings.Default.Properties)
{
  Debug.WriteLine("{0} - {1}", property.Name, property.DefaultValue);
}

这篇关于检索的app.config文件中的设置名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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