Allow define the same local variable name in different scope. #9196
Answered
by
HaloFour
dameng324
asked this question in
Language Ideas
-
In this C# code: public void Test()
{
if (true)
{
int num = 1;
Console.WriteLine(num);
}
int num = 2;
Console.WriteLine(num);
} The compiler will result these errors:
But acutally it's not make sense as they has different scope. The first It will be really nice if I can define my local var name more freely. |
Beta Was this translation helpful? Give feedback.
Answered by
HaloFour
Mar 4, 2025
Replies: 1 comment
-
See: #2574 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dameng324
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: #2574