Here is what my app has:
private void saveInDatabase(string key, string value)
switch (key)
{
case "a":
def = Helpers.Utils.listOfDoubleFromString(value);
break;
case "b":
chi = int.Parse(value);
break;
....
}
Is there a way that I could use a dictionary like this to decide what actions happen with the different case values?
{"a", () => def = Helpers.Utils.listOfDoubleFromString(value)},
{"b", () => chi = int.Parse(value)},
My app has a large number of these case statements so I am interested to know if I could replace them by setting up a dictionary and then some more code.