Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Order of Operations | Control Structures
C# Basics

Order of OperationsOrder of Operations

In case there's only one operator used multiple times then the expression is evaluated from left to right.

For the examples we will use true and false literals for simplicity. In case we have a long expression like false || false || true || false, the expression will be evaluated from the left side:

cs

main.cs

Following is a more complex example which includes multiple different operators. It will be a good code reading exercise to read and try to understand it:

cs

main.cs

In the above code, we have the expression (1 <= x) && (x <= 10) || (90 <= x) && (x <= 100), which checks if x is in the range 1-10 or 90-100.

The order of the logical operators is the following:

Considering the order of operators, the expression will be evaluated as follows:

Which operator is evaluated first?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 4
course content

Зміст курсу

C# Basics

Order of OperationsOrder of Operations

In case there's only one operator used multiple times then the expression is evaluated from left to right.

For the examples we will use true and false literals for simplicity. In case we have a long expression like false || false || true || false, the expression will be evaluated from the left side:

cs

main.cs

Following is a more complex example which includes multiple different operators. It will be a good code reading exercise to read and try to understand it:

cs

main.cs

In the above code, we have the expression (1 <= x) && (x <= 10) || (90 <= x) && (x <= 100), which checks if x is in the range 1-10 or 90-100.

The order of the logical operators is the following:

Considering the order of operators, the expression will be evaluated as follows:

Which operator is evaluated first?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 4
some-alt