goto in C#
-
Is this the only way to 'fall through' on switch statements?
int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... }
*->>Always working on my game, teach me *->>something new. cout << "dav1d\n"; -
Is this the only way to 'fall through' on switch statements?
int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... }
*->>Always working on my game, teach me *->>something new. cout << "dav1d\n";IMHO something like this would be a cludge that screams poor design. If you need to use goto to 'fall through' a switch then you need to consider redesigning your application.
switch(x) { case 0: case 1: case 2: DoAction(); break; . . . }
Probably not what your doing though. -
IMHO something like this would be a cludge that screams poor design. If you need to use goto to 'fall through' a switch then you need to consider redesigning your application.
switch(x) { case 0: case 1: case 2: DoAction(); break; . . . }
Probably not what your doing though.yeah indeed. perhaps you could consider getting each of your case statements to call functions instead of each other. not sure what your exact need is, but all i know is from previous experience that fallthrough statements come back to bite you in the butt later when you least expect them.
-
Is this the only way to 'fall through' on switch statements?
int x = 3; switch(x){ case 0: goto case 1; case 1: goto case 2; case 2: goto case 3; ... }
*->>Always working on my game, teach me *->>something new. cout << "dav1d\n";No, you can 'fall' through so long as there is no code between the case statements. And yes, it sucks. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002