Expressions


Expressions evaluate one or more operators. Most expressions and the operators therein return a value. Operators have operands: Unary operators have a right-side operand, whereas binary operators have a left-side and right-side operand. Although expression statements should assign the result of an expression, expression statements consisting of function invocation, increment, decrement, and new operators are exempted from this requirement.

With the exception of the assignment operator, operands of an expression are evaluated from left to right. Expressions can contain multiple operators; operators are evaluated in order of precedence. Use parentheses to change the precedence or simply clarify the default precedence.

Table 1-11 lists the order of precedence.

Table 1-11: Order of Precedence for Expressions

Precedence

Operator

1

array '[ ]', checked , function '()', member operator '.', new, postfix decrement , postfix increment, typeof, and unchecked operators

2

unary addition '+', casting '()', one complement '~', not '!', prefix decrement, prefix increment, unary subtraction '-'operators

3

division '/', and modulus '%', multiplication '*' operators

4

binary addition '+' and binary subtraction '-' operators

5

left-shift '<<' and right-shift '>>' operators

6

as, is, less than '<', less than or equal to '<=', greater than '>', greater than or equal to '>=' operators

7

equals '==' and not equal '!=' operators

8

Logical And '&' operator

9

Logical XOR '^' operator

10

Logical Or '|' operator

11

Conditional And '&&' operator

12

Conditional Or '||' operator

13

Conditional '?:' operator

14

Assignment '=', compound '*=, /-=, %=, +=, -=, <<=, >>=, &=, ^=, and |=', and null coalescing '??' operator




Programming Microsoft Visual C# 2005(c) The Language
Microsoft Visual Basic 2005 BASICS
ISBN: 0619267208
EAN: 2147483647
Year: 2007
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net