Search for Properties.Settings.Default

The more parameters I determined, the more I need to type when I need to modify them. So I'm looking for a shorter version of Properties.Settings.Default.varX

I tried:

Properties.Settings settings = Properties.Settings.Default;
settings.var1 = "x";
settings.var2 = "y";
settings.var3 = "Z";
Properties.Settings.Default = settings;

but Properties.Settings.Default is read-only, and the Save function has no overload.

So, is there any other way than typing Properties.Settings.Default again and again?

+5
source share
2 answers

Just try it like this:

Properties.Settings settings = Properties.Settings.Default;
settings.var1 = "x";
settings.var2 = "y";
settings.var3 = "Z";
settings.Save();
+7
source

To shorten a little what you need to type, try adding this to the original using operations

using MyProps = <your_namespace>.Properties.Settings;

and then in code you can use

MyProps.Default.Var1 = "";

<your_namespace> should be replaced with the full namespace in which the parameters are defined.

+3
source

All Articles