<分区>
Possible Duplicate:
Variable declaration in c# switch statement
我一直想知道:
当我写的时候:
switch (temp)
{
case "1":
int tmpInt = 1;
break;
}
case "1":
区域有一段代码被执行(直到中断)
现在,
来自上方的瀑布不能进入case of 2
,例如:
switch (temp)
{
case "1":
int tmpInt = 1;
case "2":
break;
}
//错误:缺少中断返回。
所以我假设,他们有不同的处决区域(case....break)。
那么为什么会出现这个错误呢?
//下面定义了冲突变量tmpInt。
附注这只是一个愚蠢的问题,但仍然很有趣。