Click here to Skip to main content
15,893,190 members
Home / Discussions / C#
   

C#

 
GeneralRe: Control cannot fall through from one case to another? Pin
OriginalGriff13-May-09 8:55
mveOriginalGriff13-May-09 8:55 
AnswerRe: Control cannot fall through from one case to another? Pin
0x3c013-May-09 0:08
0x3c013-May-09 0:08 
GeneralRe: Control cannot fall through from one case to another? Pin
Luc Pattyn13-May-09 1:20
sitebuilderLuc Pattyn13-May-09 1:20 
GeneralRe: Control cannot fall through from one case to another? Pin
OriginalGriff13-May-09 2:10
mveOriginalGriff13-May-09 2:10 
GeneralRe: Control cannot fall through from one case to another? Pin
PIEBALDconsult13-May-09 3:38
mvePIEBALDconsult13-May-09 3:38 
GeneralRe: Control cannot fall through from one case to another? Pin
molesworth13-May-09 4:29
molesworth13-May-09 4:29 
AnswerRe: Control cannot fall through from one case to another? [modified] Pin
Paulo Zemek13-May-09 3:38
mvaPaulo Zemek13-May-09 3:38 
GeneralRe: Control cannot fall through from one case to another? [modified] Pin
Paulo Zemek13-May-09 3:45
mvaPaulo Zemek13-May-09 3:45 
But remember that the goto in this case is fixed. If you need something like:

switch(x)
{
case 0:
if (someCondition)
x += 5;
else
x += 6

do other processing, and then continue with the next case for X (that can be 5, 6 or some other value) the best solution will be to use a while.
For example:

bool continueRunning = true;
while (continueRunning)
{
switch(x)
{
case 0:
// do something;
if (someCondition)
x += 5;
else
x += 6;
break;

... other cases ...

default:
continueRunning = false;
break;
}
}

So, this will:
Execute the switch with x being zero.
You can then recalculate x, and it will execute the switch again.
You can do that how many times you want. If you want to stop it, you call continueRunning = false;
And, if the value does not fall in any case, it will enter the default, with will set continueRunning to false and stops the block.

modified on Wednesday, May 13, 2009 10:07 AM

GeneralRe: Control cannot fall through from one case to another? Pin
Luc Pattyn13-May-09 3:46
sitebuilderLuc Pattyn13-May-09 3:46 
GeneralRe: Control cannot fall through from one case to another? Pin
Paulo Zemek13-May-09 3:51
mvaPaulo Zemek13-May-09 3:51 
GeneralRe: Control cannot fall through from one case to another? Pin
OriginalGriff13-May-09 5:57
mveOriginalGriff13-May-09 5:57 
AnswerRe: Control cannot fall through from one case to another? Pin
Lutosław13-May-09 8:38
Lutosław13-May-09 8:38 
QuestionDynamic Property in C# Pin
lnmca12-May-09 22:24
lnmca12-May-09 22:24 
AnswerRe: Dynamic Property in C# Pin
DaveyM6912-May-09 22:50
professionalDaveyM6912-May-09 22:50 
JokeRe: Dynamic Property in C# Pin
Giorgi Dalakishvili12-May-09 23:26
mentorGiorgi Dalakishvili12-May-09 23:26 
GeneralRe: Dynamic Property in C# Pin
DaveyM6913-May-09 2:29
professionalDaveyM6913-May-09 2:29 
QuestionEdit file as Pin
pedersen-roxen12-May-09 21:50
pedersen-roxen12-May-09 21:50 
Questionbackup database from a distant server with sql server 2000 Pin
adsana12-May-09 21:26
adsana12-May-09 21:26 
QuestionDynamically ENUM Pin
lnmca12-May-09 19:13
lnmca12-May-09 19:13 
AnswerRe: Dynamically ENUM Pin
N a v a n e e t h12-May-09 19:17
N a v a n e e t h12-May-09 19:17 
GeneralRe: Dynamically ENUM Pin
PIEBALDconsult13-May-09 13:57
mvePIEBALDconsult13-May-09 13:57 
AnswerRe: Dynamically ENUM Pin
zlezj12-May-09 23:02
zlezj12-May-09 23:02 
AnswerRe: Dynamically ENUM Pin
Guffa13-May-09 0:48
Guffa13-May-09 0:48 
AnswerRe: Dynamically ENUM Pin
Paulo Zemek13-May-09 9:00
mvaPaulo Zemek13-May-09 9:00 
QuestionStandalone application.... Pin
Rajdeep.NET is BACK12-May-09 19:03
Rajdeep.NET is BACK12-May-09 19:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.