why it's illegal?
if ypu want to know how's the rule:
The scope of a local variable declared in a local-variable-declaration is
the block in which the declaration occurs.
But:
It is an error to refer to a local variable in a textual position that
precedes the local-variable-declarator of the local variable.
if you want to know why c# does this?
See posting of James Curran
Andy Fish" <aj****@blueyonder.co.uk> schrieb im Newsbeitrag
news:uj**************@TK2MSFTNGP10.phx.gbl...
this fragment of c# does not compile:
{
{
string s = "a";
}
string s = "a";
}
It says that the 2 declarations conflict. AFAIK the scope of a variable
declaration is from the point in the source file it is declared until the
end of the enclosing block. By this definition they don't conflict
Andy