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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -