+ 2

Necessary??

in c#, is it necessary default case have break keyword??

25th Apr 2017, 12:33 PM
Mayur Chaudhari
Mayur Chaudhari - avatar
4 Réponses
+ 12
This is not C# syntax, but anyway: If you close your program, how should the compiler check, if your case ends with a break statement? That doesn't really make sense to me.
25th Apr 2017, 1:26 PM
Tashi N
Tashi N - avatar
+ 11
You need one of these statements at the end of each case: break, goto, return or throw It is mandatory to have one of this statements on each case, even for the default case.
25th Apr 2017, 12:53 PM
Tashi N
Tashi N - avatar
+ 4
No need
25th Apr 2017, 12:45 PM
Calviղ
Calviղ - avatar
+ 2
case 1: exit(0); why this is not required break keyword?
25th Apr 2017, 1:17 PM
Mayur Chaudhari
Mayur Chaudhari - avatar