问题描述
应该指定什么时候应该使用configurationManager.AppSettings或visual studio生成的强类型设置?强类型似乎在大多数情况下更合适,但我认为可以使用ConfigurationManager方法动态添加设置到已部署的应用程序,但有什么指导方针,每种情况下每个设计使用?
What should dictate when I should use the configurationManager.AppSettings or the strongly typed settings that visual studio generates? The strongly typed ones seem much more appropriate in most cases, but I suppose that it would be possible to add settings dynamically to a deployed application using the ConfigurationManager approach, but are there any guidelines under which circumstances each is designed to be used?
推荐答案
从看起来像AppSettings是做旧事的方式。
声明如果您正在使用设置,则可以在运行时写入用户设置。
From what I read, looks like AppSettings is the older way of doing things. MSDN docsstates that user settings can be written at run time if you are using settings.
我总是喜欢强类型设置,可以使用ConfigSection处理程序实现。
I always prefer strongly typed settings, which can be implemented with ConfigSection handlers.
这篇关于ConfigurationManager.AppSettings [“SettingName”] vs Properties.Settings.Default.SettingName什么时候应该使用每个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!