0
What is exactly fallthrough behaviour in c#???
2 Antworten
+ 5
Switch statement.
Switch fallthrough is historically one of the major source of bugs in modern softwares. The language designer decided to make it mandatory to jump at the end of the case, unless you are defaulting to the next case directly without processing.
switch(value)
{
case 1:// this is still legal
case 2:
}
+ 3
Falling through switch-cases can be achieved by having no code in a case, or using the special goto case or goto default forms:
switch(num) {
case 1:
case 2:
//do something
goto case 3;
case 3:
//do something
goto default;
default:
break;
}