for (int x = 5; x < 10; x++)
{
Console.WriteLine(x);
}
Console.WriteLine(x);// A local or parameter named 'x' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
int x = 10;// Cannot use local variable 'x' before it is declared
我问了 CHAT GPT 但它没有帮助我(我使用了很多不同的方法来解决这个问题)
你是否正在尝试做这样的事情:
int x = 5;
for (; x < 10; x++)
{
Console.WriteLine(x);
}
Console.WriteLine(x);