0
Do I have to write the "Default" code at the end of each "switch" statement?
I was wondering if its possible to write the default statement in between the "cases" or at the beginning of the "cases"?
2 odpowiedzi
- 1
Yes, but it makes for code that is harder to read. Ex:
int num = -1;
switch (num) {
case 0:
Console.WriteLine("0");
break;
default:
Console.WriteLine("Default");
break;
case 1:
Console.WriteLine("1");
break;
}