C# 我不能将值增加2或超过2

C# 我不能将值增加2或超过2,c#,for-loop,C#,For Loop,如何将值增加2而不是1?当我运行代码时,它将从1-10添加1,但我希望它通过添加2变为1-10 for (int x=0;x<10;x++) { Console.WriteLine(x); } for(int x=0;x如果我理解正确,这应该是您的解决方案 for (int x = 0; x < 10; x += 2) { Console.WriteLine(x); } for(int

如何将值增加2而不是1?当我运行代码时,它将从1-10添加1,但我希望它通过添加2变为1-10

  for (int x=0;x<10;x++)
  {
      Console.WriteLine(x);
  }

for(int x=0;x如果我理解正确,这应该是您的解决方案

        for (int x = 0; x < 10; x += 2)
        {
            Console.WriteLine(x);
        }
for(int x=0;x<10;x+=2)
{
控制台写入线(x);
}
您可以这样做-

for (int x = 0; x < 10;) {  
            Console.WriteLine(x);
            x = x + 2;
}
for(int x=0;x<10;){
控制台写入线(x);
x=x+2;
}

如果
x++
意味着
x=x+1
那么你需要做什么才能增加2?感谢兄弟的帮助我不明白为什么人们会否决我的问题我是编程新手