So if I have a switch with 3 cases, each case has duplicate local variables declared in them. You would think that the variables would be local to that case so you should be able to use the same name repeatedly. However, this doesn't appear to be the 'case'.
Apparently the other case blocks can see the variables in each other.
Okay, no big deal right? Except that when you try and access that variable that it can obviously see, it says it can't see it???
int index = list.SelectedIndex;
switch(index){
case(0):
bool val = true; //First declaration s'allll good
if(val) //No issues here either obviously
MessageBox.Show("Huh?");
break;
case(1):
bool val = true; //Says it already exists??
if(val)
MessageBox.Show("Huh?");
break;
case(2):
bool val3 = true; //Change the variable name so you can use it however,
if(val) //When you try to access the val in case 0 it says it doesn't exist?????
MessageBox.Show("Huh?");
break;
}
Is there an obvious syntax fold in space time I am missing here?