In my program I have some classes where data is stored. For example
Class1.alfa.dado = 66;
Class1.beta.dado = 56;
Class1.gama.dado = 37;
The user will select one of the options that you want to change in a ComboBox, in this ComboBox are the alpha, beta and gamma strings.
So I need to run a function that does more or less like this
void change (string alterar)
{
Class1.(alterar).dado = 7;
}
How to use this "change" string to access the variable?
One solution would be to use switch
. But the problem is that the functions are not so simple, they are big codes, and with switch
gets very repetitive and whenever I need to change something I have to get into a lot of places. I would like to do this more automatically.