如果在赋值语句中,自加运算符在变量的前面,那么变量先加1,然后赋值,称为运算前增量。
如果自加运算符在变量的后边,那么先赋值,然后再加1,称为运算后增量。

自减运算符表示把变量的值减1,用法与自加运算符相同。

using System;
class Program{
public static void Main(){
int a=6;
int b=8;
Console.WriteLine("a++等于{0}",a++);
Console.WriteLine("++a等于{0}",++a);
Console.WriteLine("b--等于{0}",b--);
Console.WriteLine("--b等于{0}",--b);
Console.ReadLine();

}
}

相关文章:

  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-01-28
  • 2021-05-18
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
  • 2021-09-05
  • 2021-05-15
  • 2021-12-06
相关资源
相似解决方案