Switch statement inside a switch statement?
I'd call a function that was specific to case 5, then have the switch case in that function. For example :
switch(id)
{
case 5:
FunctionFiveSpecific(id);
case 6:
// set some value
...
}
The function specific for case 5 :
private void FunctionFiveSpecific(id)
{
// other switch in here
}
The only thing that could be wrong with it is that it could hurt readability:
switch(id)
{
case 5:
{
switch (somethingElse)
{
case 1:
// blah...
}
}
case 6:
// set some value
...
}
You could improve this by moving the nested section into a method:
switch(id)
{
case 5:
Foo();
break;
case 6:
// set some value
...
}