Is it possible for one case to handle multiple values? For example, I have to run the same code for two of the several case options. Can you do something like case "value1" || "value2"?
Kind of... Do it like this
[tt]switch (expression)
{
case "value1":
case "value2":
//Code goes here
break;
case "value3":
//....
}[/tt]
The program will run starting from the matching case to the break statment. If you leave out the break statment for value1 it will just continue down to value2.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.