Possible Duplicate:
C# Variable Scoping
Consider this code:
void f()
{
if (condition)
{
B b = createB();
}
...
B b = getB();
}
I get an error complaining about variable b already defined in child scope. Why is this? The first definition occurs in nested scope which is not visible to outer scope. I can't even access the previously declared variable in outer scope. So what is the compiler doing in this case?