大约有 44,000 项符合查询结果(耗时:0.0824秒) [XML]
Error: Jump to case label
... the { }
dostuff(i);
break;
}
case 2:
dostuff(123); // Now you cannot use i accidentally
}
Edit
To further elaborate, switch statements are just a particularly fancy kind of a goto. Here's an analoguous piece of code exhibiting the same issue but using a goto instead of...
LINQ to SQL Left Outer Join
...
logical8
83288 silver badges1212 bronze badges
answered Mar 31 '09 at 8:33
Marc Gravell♦Marc Gravell
...
Preventing form resubmission
...
iweiniwein
23.5k88 gold badges6565 silver badges105105 bronze badges
add a co...
How to play audio?
...
Obsidian Age
34.8k88 gold badges3333 silver badges5353 bronze badges
answered Feb 23 '12 at 18:53
shanabusshanabus
...
npm - install dependencies for a package in a different folder?
...
Linus ThielLinus Thiel
35.4k88 gold badges9898 silver badges9797 bronze badges
...
Assign null to a SqlParameter
...
Chris TaylorChris Taylor
47.5k88 gold badges6868 silver badges8585 bronze badges
...
Is there a way to loop through a table variable in TSQL without using a cursor?
...
p.campbell
88.7k5959 gold badges237237 silver badges312312 bronze badges
answered Sep 16 '08 at 21:55
SeibarSeib...
How to get the index of an element in an IEnumerable?
...
Marc Gravell♦Marc Gravell
888k227227 gold badges23562356 silver badges27202720 bronze badges
...
Testing Private method using mockito
...
shift66shift66
10.6k88 gold badges4444 silver badges7474 bronze badges
...
Using {} in a case statement. Why?
... case 42:
int x = GetSomeValue();
return a * x;
case 1337:
int x = GetSomeOtherValue(); //ERROR
return a * x;
}
You will get a compiler error because x is already defined in the scope.
Separating these to their own sub-scope will eliminate the need to declare ...
