I have added App.config file in my project. I have created two settings from Project > Properties > Settings panel -
我注意到,当我添加一个设置时,我可以将范围定义为用户
或应用程序
-
- 用户
- 应用程序
If I define setting as 用户
it goes touserSettings
section,
if I define setting as 应用程序
it goes to applicationSettings
section
App.config
<configuration>
<userSettings>
<DemoApp.Properties.Settings>
<setting name="MySetting1" serializeAs="String">
<value>Value1</value>
</setting>
</DemoApp.Properties.Settings>
</userSettings>
<applicationSettings>
<DemoApp.Properties.Settings>
<setting name="MySetting2" serializeAs="String">
<value>Value2</value>
</setting>
</DemoApp.Properties.Settings>
</applicationSettings>
</configuration>
但是,这些设置可以通过相同的方式从.cs
-
Code
string mySetting1 = DemoApp.Properties.Settings.Default.MySetting1;
string mySetting2 = DemoApp.Properties.Settings.Default.MySetting2;
用户
和应用程序
范围之间有什么区别?在什么情况下应该在这两者之间进行 Select ?