In the programming of C # language, relational expressions and logical expressions are often used, or mixed use of both.
1. relational expressions are made up of relational operators. For example:>,<,>=,<=,= = ,!=. An expression that uses these operators is called a relational expression. Examples are as follows:
int number_01;
int number_02;
Enter A value for number_01
Console.Write (" Please enter The value of number_01:");
Number_01=console.readline ();
Enter A value for number_02
Console.Write (" Please enter The value of number_02:");
Number_02=console.readline ();
if (number_01==number_02)
{
Console.WriteLine ("Number_01 and number_02 equal ");
}
if (number_01!=number_02)
{
Console.WriteLine ("Number_01 and number_02 Not equal ");
}
if (number_01>number_02)
{
Console.WriteLine ("Number_01 greater than number_02");
}
if (number_01>=number_02)
{
Console.WriteLine ("Number_01 greater than or equal to number_02");
}
if (number_01<number_02)
{
Console.WriteLine ("Number_01 less than number_02");
}
if (number_01<=number_02)
{
Console.WriteLine ("Number_01 less than or equal to number_02");
}
2. logical expressions are made up of logical operators. Mainly include:&,| , ! , ^ .
rules for logic and & :
Logical and logical values on both sides are true, the result is true; otherwise false.
True&true=true
True&false=false
False&true=false
False&false=false
Logical OR rule:
Logical or logical values on either side are true, as long as there is one, the result is true.
True|true=true
True|false=true
False|true=true
False|false=false
The logic is not to take the opposite value.
! false=true
!true=false
Logical XOR:
Logical XOR is false for both sides of the value , and the other case is true.
True^true=false
True^false=true
False^true=true
False^false=false
This article is from the "Smile" blog, please be sure to keep this source http://yiyiweixiao.blog.51cto.com/2476874/1969133
9, C # inside the relationship expression, logical expression