I am very new to C# and using Visual Studio 2015 as my development environment. I have done my best to search for existing answers, but have not been able to find anything that seems relevant to my question.
I want to have application settings stored in config file (5 optional strings along with 5 booleans) Along with each string I want to store an associated boolean that indicates whether or not the optional value or default value should be used. I need to use these values in a method that replaces every instance of a certain string with the user specified string providing the boolean returns true and loops over each string flagged by a positive boolean.
I do not feel as if I have explained myself properly, so here are some basic rules that outline what I wish to implement.
- Settings form should have 5 check boxes next to 5 text boxes.
- For each check box marked true, input string from the associated text box should be stored in a config file.
- Along with each stored string there needs to be a boolean value (obtained via check-box state)
My settings form looks something like the following.
The empty square brackets at the start of each line represents the check box and the square brackets with Xs in it ([xxxxxx]) represent the text boxes used to obtain user defined strings.
___________________________________________________________________________________________________
SETTINGS FORM
[ ]:use my own string for element 1 [xxxxxxx]: custom string 1
[ ]:use my own string for element 2 [xxxxxxx]: custom string 2
[ ]:use my own string for element 3 [xxxxxxx]: custom string 3
[ ]:use my own string for element 4 [xxxxxxx]: custom string 4
[ ]:use my own string for element 5 [xxxxxxx]: custom string 5
[Cancelbutton] [Savebutton]
____________________________________________________________________________________________________
Im specifically interested in how I should go about storing user specified strings and associated boolean values in order to retrieve them considering the following requirements...
- The method that uses these values should loop through each element...where the check-box is true it should replace a string from a data stream with the user defined string.
- Config file should not be updated until the user presses the "Save" button
- These settings need to persist until they are changed
I feel like I have done a poor job at explaining what I wish to achieve here, and am happy to provide further clarification as needed.