| View previous topic :: View next topic |
| Author |
Message |
wunder312355 Grandmaster Cheater
Reputation: -1
Joined: 14 May 2007 Posts: 568
|
Posted: Sat May 30, 2009 8:48 pm Post subject: [c#]Break statement |
|
|
Does break; have to be used in switch statements in C#?
If I don't use them, I get this error:
| Quote: | | Control cannot fall through from one case label ('case 1:') to another |
|
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sat May 30, 2009 9:37 pm Post subject: |
|
|
Yes, break means that's the end of the commands to do in that case.
One of the lessons in my tutorials is all about switch statements.
Link in my signature
VVVVVVVVVVVVVVV
_________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat May 30, 2009 9:40 pm Post subject: |
|
|
| Quote: | | 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. |
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun May 31, 2009 7:14 am Post subject: |
|
|
| slovach wrote: | | Quote: | | 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. |
|
Wow, talk about lame. Why did they do that?
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Sun May 31, 2009 9:12 am Post subject: |
|
|
Edit : Sorry didn't read the question properly. Yes you need to break the loop.
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun May 31, 2009 10:50 am Post subject: |
|
|
| Noz3001 wrote: | | slovach wrote: | | Quote: | | 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. |
|
Wow, talk about lame. Why did they do that? | I'm wondering that too.. Now you can't do eg. | Code: | case PROCESS_NEXT:
++index;
case PROCESS_CURRENT:
v.at(index)->Process();
break; |
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sun May 31, 2009 12:16 pm Post subject: |
|
|
Yea you'd have to do:
| Code: |
case PROCESS_NEXT:
case PROCESS_CURRENT:
if (i == PROCESS_NEXT)
++index;
v.at(index)->Process();
break;
|
Kinda dumb but w/e.
_________________
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Sun May 31, 2009 12:23 pm Post subject: |
|
|
This is what I'd like the syntax to be. For me it would make more sence. But maby that is just me and my crazy thinking.
select (shit)
{
case lol
{
}
}
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
iostream How do I cheat?
Reputation: 0
Joined: 06 Apr 2009 Posts: 9 Location: georgia
|
Posted: Sun May 31, 2009 7:13 pm Post subject: |
|
|
| yoyonerd wrote: | Yes, break means that's the end of the commands to do in that case.
One of the lessons in my tutorials is all about switch statements.
Link in my signature
VVVVVVVVVVVVVVV |
you should continue those.
also @OP check out msdn as they now offer a pretty good video series that cover c# pretty well.
_________________
Don't wait up. |
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun May 31, 2009 7:59 pm Post subject: |
|
|
| iostream wrote: | | yoyonerd wrote: | Yes, break means that's the end of the commands to do in that case.
One of the lessons in my tutorials is all about switch statements.
Link in my signature
VVVVVVVVVVVVVVV |
you should continue those.
also @OP check out msdn as they now offer a pretty good video series that cover c# pretty well. |
I am actually, now that I'm on break, I actually have the time.
I will also start writing guides focused more on bot making programming.
You'll be able to find these in the w8baby.com programming section
_________________
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Mon Jun 01, 2009 4:26 am Post subject: |
|
|
| iostream wrote: | | yoyonerd wrote: | Yes, break means that's the end of the commands to do in that case.
One of the lessons in my tutorials is all about switch statements.
Link in my signature
VVVVVVVVVVVVVVV |
you should continue those.
also @OP check out msdn as they now offer a pretty good video series that cover c# pretty well. |
continue will only jump to the next statement. so in a select case it wouldn't abort the actual loop like break would.
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
|