Home News DOC Class DL Others Cooker
Documents  >  Tutorial  >  Operators
Operators

An operator is a symbol that specifies the operation to be performed on an instance. The operator performs an operation on the operand and returns an instance of the result.


Table of contents:


Priority

Change priority

Priority

Operators have priorities. Expressions that contain multiple operators are computed from operators with higher priorities.

The following is a list of operators. The smaller number is the higher priority. If operators with the same priority are adjacent, the operation is executed in order from the left of the expression.


Priority 1
()x(y)Method call operator
newnew int()new operator
thisthisthis operator
[]x[y]Indexer operator
Priority 2
.x.yDot operator
++x++Postfix ++ operator
--x--Postfix -- operator
Priority 3
++xUnary + operator
--xUnary - operator
!!xLogical negation operator
++++xPrefix ++ operator
----xPrefix -- operator
Priority 4
*x * yMultiplication operator
/x / yDivision operator
%x % yModulo operator
Priority 5
+x + yAddition operator
-x - ySubtraction operator
Priority 6
<x < yLess than operator
<=x <= yLess than or equal operator
>x > yGreater than operator
>=x >= yGreater than equal operator
Priority 7
==x == yValue equality operator
!=x != yValue inequality operator
$$x $$ yReference equality operator
!$x !$ yReference inequality operator
Priority 8
&x & yLogical AND operator
Priority 9
|x | yLogical OR operator

Change priority

Use parentheses to change the priority of operations. Expressions in parentheses are preferentially operated.


int i = (2 + 2) * 2; // 8

Next
Previous
Copyright © Rice All rights reserved.