C# logical operators and analysis

Article Directory

  • Blogger writing is not easy, kids need your encouragement
  • Thousands of waters and thousands of mountains are always in love, so please click a like first.

Logical operators are used to connect one or more conditions to determine whether these conditions are true.

C # logical operators can be divided into two
categories: "&" "|" "^" called the whole logical operators , they allow Boolean operations on two
values; "&&" "||" "!" Said For conditional logic operators , the values ​​of the operands on both sides of the operator must be of Boolean type, and the operands are often conditional expressions.

Operator Description
!= Compare whether two values ​​are not equal
== Compare two values ​​for equality
& Generate the bitwise AND of the two operands
&& Istanbul and ; when both operands are true when the result is TRUE , the remaining cases are FALSE
l Generate the bitwise OR of two operands
ll Boolean or ; if one of the at least two operands are true when the result is TRUE , the remaining cases are FALSE
^ Generate bitwise exclusive OR of two operands
! Conditions Non ; Boolean operands results negated.

Note:
1. & is a bitwise AND of numerical value, && can only be used for logical operation of Boolean value;
2. | is a bitwise OR of numerical value, || can only be used for logical operation of Boolean value;
3. Priority Level, from low to high: ==,! =;&;^;|;&&;||.

  • About the blogger:
  • Industrial automation upper computer software engineer, machine vision algorithm engineer, motion control algorithm engineer. Currently working in the intelligent manufacturing automation industry. Blogger's mailbox: [email protected]
  • Help me like it. Haha.

Guess you like

Origin blog.csdn.net/cashmood/article/details/109159654