Dun*_*oud 4 .net c# settings c#-4.0
我需要从app.config文件中检索密钥设置的名称.
例如:
我的app.config文件:
<setting name="IGNORE_CASE" serializeAs="String">
<value>False</value>
</setting>
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用以下方法检索值:
Properties.Settings.Default.IGNORE_CASE
Run Code Online (Sandbox Code Playgroud)
有没有办法从我的键设置中获取字符串"IGNORE_CASE"?
此处的示例代码显示了如何遍历所有设置以读取其键和值.
摘录方便:
// Get the AppSettings section.
// This function uses the AppSettings property
// to read the appSettings configuration
// section.
public static void ReadAppSettings()
{
// Get the AppSettings section.
NameValueCollection appSettings =
ConfigurationManager.AppSettings;
// Get the AppSettings section elements.
for (int i = 0; i < appSettings.Count; i++)
{
Console.WriteLine("#{0} Key: {1} Value: {2}",
i, appSettings.GetKey(i), appSettings[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2841 次 |
| 最近记录: |