One, C # logical operators
The logical operator of the C # language is to compare the value of a variable, the result of an expression, and the result of a base comparison is true or false.
Ii. examples
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Namespace Test
{
Class Program
{
static void Main (string[] args)
{
C # logical operator-www.baike369.com
Console.WriteLine ("With Operator:" + (1 > 2 & 2 < 3)); Comparison of BOOL Types
Console.WriteLine ("Or Operator:" + (1 > 2 | 2 < 3));
Console.WriteLine ("Xor Operator:" + (1 > 2 ^ 2 < 3));
Console.WriteLine ("Logical Non-operator:" +! ( 1 < 2));
Console.WriteLine ("Logical AND Operator:" + (1 > 2 && 2 < 3));
Console.WriteLine ("Logical OR Operator:" + (1 > 2 | | 2 < 3));
Console.ReadLine ();
}
}
}
Operation Result:
With operator: False
Or operator: True
Xor Operator: True
Logical non-operator: False
Logic and operators: False
Logical OR Operator: True
C # logical operators