How to get Properties.Settings.Default property using string?

I have a Winforms / C # application and I transfer from the xml configuration file to the application settings. I would like to know if it is possible to access the dynamic settings of the application (Properties.Settings.Default).

I have 4 configurations for my application with the corresponding parameters, which I logically named name1, name2, name3, name4, server1, server2, etc. Instead of giving them a value like

Properties.Settings.Default.name1 = textbox.txt;

I would like to do something similar with respect to the configuration to which they belong:

class ApplicationSettings
{

    int no;

    ApplicationSettings(int no)
    {
        this.no = no;
    }

    private void save()
    {
        Properties.Settings.Default.Properties["name"+no] = "value";
    }

}

This technique only works for SettingsProperties, as shown here . Do you know if there is a way to do this?

+4
source share
1

[] , :

internal static class ApplicationSettings
{

    //added public static because I didn't see how you planned on invoking save
    public static void Save(int no, string value)
    {
        //sets the nameX
        Properties.Settings.Default["name"+no.ToString()] = value;
        //save the settings
        Properties.Settings.Default.Save();
    }

}

ApplicationSettings.Save(1,"somesetting");
+7

All Articles