Boolean Logical Operator

Why Trust Techopedia

What Does Boolean Logical Operator Mean?

A Boolean logical operator in the context of C# programming language is an operator used to perform Boolean logic upon two Boolean expressions.

Advertisements

Boolean logical operators return Boolean results (true or false) and take Boolean values as operands. While performing Boolean logic, the expression on the left is evaluated, followed by the expression on the right. The two expressions are finally evaluated in the context of the Boolean logical operator between them. The return value is of Boolean type and based on the operator type used.

Techopedia Explains Boolean Logical Operator

Boolean logical operators can be used to test or adjust the value of a Boolean variable. The result of the expression using these operators can be used in conditional statements to control the program flow through the code.

Boolean logical operators have precedence in the order shown below:

  1. Logical AND (&)
  2. Logical XOR (^)
  3. Logical OR (|)

It is vital to understand the difference between the & and && operators when they are used in an expression where two conditions have to be evaluated. While the & operator always executes both conditions, && does not execute the second on failure of the first. The || operator works similar to && by skipping the conditions after the first, if the first condition is true. Hence, && and || (referred to as conditional logical operators) are called short circuit operators.

The ^ operator works in a similar way to |. The | and || operators (and & and && operators) are not interchangeable since they operate differently.

Advertisements

Related Terms

Margaret Rouse
Editor

Margaret jest nagradzaną technical writerką, nauczycielką i wykładowczynią. Jest znana z tego, że potrafi w prostych słowach pzybliżyć złożone pojęcia techniczne słuchaczom ze świata biznesu. Od dwudziestu lat jej definicje pojęć z dziedziny IT są publikowane przez Que w encyklopedii terminów technologicznych, a także cytowane w artykułach ukazujących się w New York Times, w magazynie Time, USA Today, ZDNet, a także w magazynach PC i Discovery. Margaret dołączyła do zespołu Techopedii w roku 2011. Margaret lubi pomagać znaleźć wspólny język specjalistom ze świata biznesu i IT. W swojej pracy, jak sama mówi, buduje mosty między tymi dwiema domenami, w ten…