Original Post
If I have a switch statement in a loop: I know I can skip a case using the "continue" keyword. How can I create a flag that will be able to skip multiple cases if necessary. For example, if the result of case 1 is true then I flag case 4 to be skipped. If the result of case 2 is also true then I would like case 6 to be skipped. Therefore case 4 and 6 will now be skipped using the continue keyword based on checking a single flag. Can anyone please explain how this would be possible to achieve without using multiple booleans for each possible case that could be skipped? Thank you.
for (int i = 0; i < 7; ++i)
{
switch (i)
{
case 0:
// Do stuff here
break;
case 1:
// Do stuff here
break;
case 2:
// Do stuff here
break;
case 4:
// Do stuff here
break;
case 5:
// Do stuff here
break;
case 6:
// Do stuff here
break;
}
}