A
Amil
Am I missing something there and just being a bonehead or what? When I
compile the code below, the compiler warns "A local variable named 'foo'
cannot be declared in this scope because it would give a different meaning
to 'foo', which is already used in a child scope to denote something else".
I can't have PREVIOUS foo uses in nested scopes? What am I missing here??
I guess the compiler is not smart enough to see that the last foo doesn't
have any nested foo declarations after it. ^%$@!*^&!
static void Main(string[] args)
{
if (true)
{
int foo = 3;
}
if (true)
{
int foo = 57;
}
int foo = 5; // THIS LINE IS FAILING COMPILER "Compiler Error CS0136"
Console.WriteLine(foo);
}
compile the code below, the compiler warns "A local variable named 'foo'
cannot be declared in this scope because it would give a different meaning
to 'foo', which is already used in a child scope to denote something else".
I can't have PREVIOUS foo uses in nested scopes? What am I missing here??
I guess the compiler is not smart enough to see that the last foo doesn't
have any nested foo declarations after it. ^%$@!*^&!
static void Main(string[] args)
{
if (true)
{
int foo = 3;
}
if (true)
{
int foo = 57;
}
int foo = 5; // THIS LINE IS FAILING COMPILER "Compiler Error CS0136"
Console.WriteLine(foo);
}