Home > Software engineering >  How to set variable to Properties.Settings.Default instead of setting name?
How to set variable to Properties.Settings.Default instead of setting name?

Time:05-20

For example I do save to App.config like this:

int SaveInteger = %ANY INTEGER%
Properties.Settings.Default.X_Position = SaveInteger;
Properties.Settings.Default.Save();

I make a string variable that contains the name of the setting, depending on the work of the program:

string Some_Setting = %ANY SETTING NAME%;

So the main question is how i can set variable Some_Setting to Properties.Settings.Default.%SettingName% instead of setting name?

CodePudding user response:

The base class has the Item[String] Property.

That means you can do

Properties.Settings.Default["settingName"] = whateverValue;

For reference: ApplicationSettingsBase.Item[String] Property

  • Related