I use the built-in settings provided by Visual Studio to store simple application settings. Until now, I’ve accessed this in my application by using the convention:
Properties.Settings.Default.MySetting
And then call methods like Save by using:
Properties.Settings.Default.Save()
However, someone recently told me that it is more correct to access the properties by creating a member variable like this:
private Properties.Settings settings = new Properties.Settings()
And then using the member settings to access properties and methods like:
settings.MySetting
settings.Save()
I vaguely recall that they justified this by describing differences in the way the settings are stored in the user’s area.
Can anyone confirm or give further details on the differences? Many thanks.
Settings.Defaultis initialized as follows:So it’s almost the same as manually creating an instance of
Settings, except that the one provided bySettings.Defaultis a synchronized instance. I can’t see any good reason to create an instance ofSettingsmanually…