Possible duplicate:
C # variable zoom
I ran into something that I had never encountered. I am not looking for a fix because I know how to solve it. What I would like to know is what the compiler does. This is just a sample code:
if (true) { int x = 0; } int x = 0;
This code generates the error "Local variable" x "cannot be declared in this area because it will have a different value of" x ".
However, I am changing the code to this:
if (true) { int x = 0; } x = 0;
I get the error "Unable to resolve the character" x ".
So what is going on here? How is it that x is both a scope and inoperable?
source share