Skip to content

Operators

Pedro Marques edited this page Aug 8, 2019 · 4 revisions

Expressions can be combined using operators. Each operator as a precedence priority. Here is the list of those expression's priority.

  1. primary
  2. unary
  3. multiplicative
  4. additive
  5. relational
  6. logical

Logical

These operators can do some logical comparison between other expressions: or, || and, &&

  true or false and true

The and operator has more prioroty thand the or, thus in the example above, false and true is evaluated first.

Relational

=, ==, !=, <> <, <=, >, >=

  1 < 2

Additive

+, -

  1 + 2 - 3

Multiplicative

*, /, %

 1 * 2 % 3

Bitwise

& (bitwise and), | (bitwise or), ^(bitwise xor), << (left shift), >>(right shift)

  2 >> 3

Unary

!, not, -, ~ (bitwise not)

  not true

Primary

(, ) values

  2 * ( 3 + 2 )

Note:

From v1.4.3, operations between decimal and floating point numbers convert the floating point number to a decimal. This may lead to a loss of precision as

Convert.ToDecimal(10e-30) == 0
Clone this wiki locally