* Expressions* are constructed from

When an expression contains multiple operators, the * precedence* of the operators controls the order in which the individual operators are evaluated. For example, the expression x + y * z is evaluated as x + (y * z) because the * operator has higher precedence than the + operator.

Most operators can be * overloaded*. Operator overloading permits user-defined operator implementations to be specified for operations where one or both of the operands are of a user-defined class or struct type.

The following table summarizes C#’s operators, listing the operator categories in order of precedence from highest to lowest. Operators in the same category have equal precedence.

| | |

Primary | x.m | Member access |

x(...) | Method and delegate invocation | |

x[...] | Array and indexer access | |

x++ | Post-increment | |

x-- | Post-decrement | |

new T(...) | Object and delegate creation | |

new T(...){...} | Object creation with initializer | |

new {...} | Anonymous object initializer | |

new T[...] | Array creation | |

typeof(T) | Obtain System.Type object for T | |

checked(x) | Evaluate expression in checked context | |

unchecked(x) | Evaluate expression in unchecked context | |

default(T) | Obtain default value of type T | |

delegate {...} | Anonymous function (anonymous method) | |

Unary | +x | Identity |

-x | Negation | |

!x | Logical negation | |

~x | Bitwise negation | |

++x | Pre-increment | |

--x | Pre-decrement | |

(T)x | Explicitly convert x to type T | |

Multiplicative | x * y | Multiplication |

x / y | Division | |

x % y | Remainder | |

Additive | x + y | Addition, string concatenation, delegate combination |

x – y | Subtraction, delegate removal |

Shift | x << y | Shift left |

x >> y | Shift right | |

Relational and type testing | x < y | Less than |

x > y | Greater than | |

x <= y | Less than or equal | |

x >= y | Greater than or equal | |

x is T | Return true if x is a T, false otherwise | |

x as T | Return x typed as T, or null if x is not a T | |

Equality | x == y | Equal |

x != y | Not equal | |

Logical AND | x & y | Integer bitwise AND, boolean logical AND |

Logical XOR | x ^ y | Integer bitwise XOR, boolean logical XOR |

Logical OR | x | y | Integer bitwise OR, boolean logical OR |

Conditional AND | x && y | Evaluates y only if x is true |

Conditional OR | x || y | Evaluates y only if x is false |

Null coalescing | X ?? y | Evaluates to y if x is null, to x otherwise |

Conditional | x ? y : z | Evaluates y if x is true, z if x is false |

Assignment or anonymous function | x = y | Assignment |

x | Compound assignment; supported operators are *= /= %= += -= <<= >>= &= ^= |= | |

(T x) => y | Anonymous function (lambda expression) |

Content

License.

All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.

Copyright 2016 © ELTASK.COM. All rights reserved.

Site is optimized for mobile devices.

Downloads: 554 / 158676802. Delta: 0.07219 с

Site is optimized for mobile devices.

Downloads: 554 / 158676802. Delta: 0.07219 с