Question about the "switch" statement
Hey guys, quick question.
When you use a switch statement, does it evaluate the condition once or every time it is tested against a case? I imagine it would be the former, since that's much more efficient, but I need to make sure. For example:
Would this code test each case against a different random number, or would it store the random number and then test it against each case? Either way it's a simple fix; if it's the former, I can just do:
switch (random.Next(0, 2))
The better code depends on when the switch statement and how the switch statement checks the cases. That's my question.
int randomNumber = random.Next(0, 2);
Thanks in advance :)