C # Learning-basic introduction (3) expressions and operators in C #
Expressions and operators in C #
An expression consists of operands and operators
Operator: +-* /%
Self-increment and self-subtraction operator: bounded _ subtractive + (take the value first, then increase); bounded _ Musi _ a (first subtract, then take the value)
Assignment operator =: you need to pay attention to the implicit conversion of the value types on the left and right sides of the assignment.
Relational (comparison) operator: > = < =! =
Logical operator: no! And & & or | (if you use & or |, the efficiency is not & &, | High efficiency)
Bit operator: bitwise and operation 5-4-4. Because 5: 00101, 4: 00100, bitwise and get 00100
Bitwise or operational 3 | 6 / 7. Because 300011,600110, bitwise or get 00111 bitwise inverse operation ~ 7 instead of-8. Because 700000111, bitwise inversion results in 11111000 bitwise XOR 10 ^ 3 = 9. Because 100010103000011, you get 001001 by bit XOR.
Shift operation: the shift to the left is to the power of * 2. Moving a few places to the right is divided by two to the power.
Special operator:
Priority of the operator: the priority of the following figure is from top to bottom, from high to low. (combination means sibling from right to left, left to right)