如何在不保存C#的情况下设置应用程序设置 [英] How to set app settings without save in c#

查看:85
本文介绍了如何在不保存C#的情况下设置应用程序设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们要开发一个应用程序,该应用程序从json文件中获取配置项,并将键和值存储在ConfigurationManager.AppSettings中.但是AppSettings词典是只读的.我们不想要更新或保存app.config文件.此操作必须在内存中.有什么办法吗?

We want to develop an application that gets the configuration items from a json file and stores the key&values at ConfigurationManager.AppSettings. But AppSettings dictionary is readonly. We don't want to update or save the app.config file. This operation have to be at memory. Is there any way to do this?

推荐答案

答案非常简单.我发现其他主题很深.

The answer was so easy. I found in the deep of other topics.

answer

ConfigurationManager.AppSettings.Set(configItem.Key,configItem.Value.ToString());

这篇关于如何在不保存C#的情况下设置应用程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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