I need to save to a different setting based on the input string. Why will this line not work?
Properties.Settings.Default + colorOptionNametoSave = selectedIndexString;
Properties.Settings.Default.Save();
Where the colorOptionNametoSave is a different color setting and the selectedIndexString is the value to save. However I get the message:
Error 2: The left-hand side of an assignment must be a variable, property or indexer.
The only work around I can think of is a switch statement, but I have a lot of colors so that would be really long. Any ideas on a more efficient solution?
if/elseor aswitchis what you are looking for.You cannot concatenate a variable name!
So a solution for you would be something like this ( if
colorOptionNametoSaveis a string ):