C# Control cannot fall through from one case label to another?
I'm having this problem with this piece of code, and i don't really get what the problem is, maybe is because i am already too sleepy to concentrate enough but maybe you guys can help me:
switch(plazo){ case 1: plazo = 12; break; case 2: plazo = 24; break; case 3: plazo = 36; break; default: Console.WriteLine("Ingrese un plazo valido de 1 a 3"); } sorry if you don't understand the messages printing, it's Spanish. anyway the error says Control cannot fall through from one case label to another and it highlights the switch statement, i had this switch within a do-while loop, and i thought that might be the problem. but it wasn't :( i hope you can help me. many thanks :) |
You are getting that error because in C#, every case needs to end with either goto, break, or return. The proper way for your example would be the following:
Code:
switch(plazo){ |
Quote:
|
Not a problem.
Cheers, Josh |
All times are GMT -5. The time now is 09:29 PM. |