c# - "Cannot fall through" Switch Error -
} else { int indexgenerator = numbergenerator.next(1, 4); int answer1 = finaluserinput - thecorrectanswer; switch (indexgenerator) { case 1: console.writeline("you off by" + answer1); case 2: console.writeline("so close. maybe if add or subtract " + answer1 + "?");
when try switch work, error message pops saying control case cannot fall through case1 another.
you need add break;
@ end of each case in switch statement.
switch (indexgenerator) { case 1: console.writeline("you off by" + answer1); break; case 2: console.writeline("so close. maybe if add or subtract " + answer1 + "?"); break; }
Comments
Post a Comment