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"?

17th Nov 2016, 11:44 AM
Zebiano
2 Respuestas
- 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; }
17th Nov 2016, 4:38 PM
Robot
Robot - avatar