C# 语言基础(++和--运算)
++和--运算:
Console.Title = "++和——运算";
int a=10, b=20;
a++; b--; // ++ 就是加1,--就是减一
Console.WriteLine("a="+a); //输出a和b的值
Console.WriteLine("b="+b);
int a=10, b=20;
Console.WriteLine("a=" + (a++));//先调用a,然后在计算a+1
Console.WriteLine("a="+a);// 输出调用后a的值
Console.WriteLine("a=" + (++a));//先计算a+1的值,再调用a
Console.WriteLine("a="+a);//输出计算后a的值
Console.WriteLine("b=" + (b--));
Console.WriteLine("b=" + b);
Console.WriteLine("b=" + (--b));
Console.WriteLine("b=" + b);
int a = 10, b = a++; //先将a值赋给b,在计算a+1
Console.WriteLine("a="+a);
Console.WriteLine("b="+b); //先调用a=10.再计算a+1
int c= 10, d = ++c; //先计算c+1=11,再赋值给b
Console.WriteLine("c="+c);
Console.WriteLine("d="+d);
int a = 10, b = 17;
Console.WriteLine("a+b=" + (a + b));//加法运算
Console.WriteLine("a-b="+(a-b));//减法运算
Console.WriteLine("a/b取余="+a%b);//10除以17余 17.
Console.WriteLine("a*b=" + a * b);//10乘以17
Console.WriteLine("a/b=" + a / b);//10除以17.整型取商