We all know that in C++, the following switch statement is not conventional, but perfectly fine.
char keystroke = getch();
switch( keystroke ) {
case 'a':
case 'b':
case 'c':
case 'd':
KeyABCDPressed();
break;
case 'e':
KeyEPressed();
break;
default:
UnknownKeyPressed();
break;
}
But in C#, this is not OK. "C# does not support an implicit fall through from one case label to another. The one exception is if a case statement has no code." Therefore, C# does not support implicit "goto" with "switch". But why?
No comments:
Post a Comment