Possible Duplicate:
Variable declaration in c# switch statement
I've always wonderd :
when i write :
switch (temp)
{
case "1":
int tmpInt = 1;
break;
}
the case "1":
region has a region of code which is executed ( until break)
now ,
a waterfall from above can't get into a case of 2
e.g. :
switch (temp)
{
case "1":
int tmpInt = 1;
case "2":
break;
}
//error : break return is missing.
So i assume , they have different regions of executions ( case....break).
so why this errors appears ?
//conflict variable tmpInt is defined below.
p.s. this is just a silly question , still interesting.