Is there a way to use a switch statement to set the value of one particular variable used throughout the cases? At the moment if value is 1, I want variable to be 1, and if value is 2, I want variable to be 2. I am actually doing it simply by:
Int variable = value;
..however, for future reference where an example is more complex, I wondered if there is a way. (currently getting a variable is already defined error).
switch (value)
{
case 0:
int Variable = 0;
break;
case 1:
int Variable = 1;
break;
case 2:
int Variable = 2;
break;
case 3:
int Variable = 3;
break;
case 4:
int Variable = 4;
break;
}