关于布尔:
带有关系或等于运算符的二元表达式返回布尔值
例子:
int x=5;
if (x) //错,x是int类型,在C#中数字不具有布尔意义
...
if (x==5) //对,返回true
class Program
{
static void Main(string[] args)
{
int x = 5, y = 4;
Console.WriteLine("x==x is {0}", x == x);
Console.WriteLine("x==y is {0}", x == y);
Console.ReadKey();
}
}
}
输出结果:
x==x is true
x==y is false
递增,递减运算符:
例子: