1 namespace 逻辑表达式
2 {
3 class Program
4 {
5 static void Main(string[] args)
6 {
7 int age = 20, weight = 100;
8 //bool result = age >= 20 && weight >= 110; //与运算〉〉〉运算结果为False |运算步骤为,先进行关系运算,后进行与运算
9 bool result = age >= 20 || weight >= 110; //或运算〉〉〉运算结果为True |只要有一个条件成立结果就为True
10 Console.WriteLine(result);
11 Console.WriteLine(!result);
12 Console.ReadKey();
13 }
14 }
15 }
16 /*
17 (1)&&逻辑与:两边的表达式能求解成bool类型(整个逻辑与运算的结果也是bool类型)
18 两个表达式全部为True,逻辑与结果为True,一个为True,结果为False,全部为False,结果为False
19 (2)||逻辑或:两边的表达式能求解成bool类型(整个逻辑或运算的结果也是bool类型)
20 两个表达式全部为True,逻辑与结果为True,一个为True,结果为True,全部为False,结果为False
21 (3)!逻辑非:在bool类型表达式前加!(bool类型表达式),意为取非。取相反值<<!后只能跟bool类型>>*/