Possible Duplicate:
Child Scope & CS0136
C# Variable Scoping
Though I have been using C# for quite some time, I have just stumbled upon this error.
If I have the following:
if(true)
{
int x = 0;
}
int x = 0;
I get an error that says: A local variable named 'x' cannot be declared in this scope because it would give a different meaning to 'x', which is already used in a child scope to denote something else.
And if I do this:
if(true)
{
int x = 0;
}
x = 0;
I get an error that says: The name 'x' does not exist in the current context.
I can understand having one or the other, but why do both of these errors exist? Is there a way around the first option? I find it very annoying.
Thanks.
int Ҳ, ҳ, א, ẋ, ẍ;
I'm sure that no one will thank you later if you choose to mix these characters into your source code. :) (Just in case it's not clear to anyone reading this...please please please don't use exotic characters like these just so that you can have different variables with similar-looking names) – Substantiate