Article Directory
1. Definition of expression
We can be simply understood as the expression:Syntax entity devoted to the evaluation of.
C #, Expression 4 is obtained by evaluating the class value: single value; object (Object); method; namespace
note:
(1) An expression is a basic arithmetic logic (minimum) unit, intended to express certain algorithm
(2) Since the operator has a priority, so the expression will have priority
2. Overview of various types of expression
After all operational entity syntax to get a value, is an expression; we can say: there is meaning in C # for all operators, it is to constitute expressions.
Every Value has an associated type.
Here "value" means a value generated through the operation expression
Expression produces a value after operation, and this value also has its own data type, we say: the data type of the value expression produced, is the data type of the expression.
Analysis:
data type value expressions by the operator after the operation consisting of generating (Expression data type)
Note that the expression of several operator of the class consisting of
(1) Pre / post-increment and decrement the
Note the distinction between the expression values of the operands
(2)default
The data type of the operand data and result of the expression of the same type produced by
(3) null values union operator: ??
Expression data type by the operator of the composition is determined by "??" data type of operands of parameter type left
(4) the conditional operator: "?:"
The operator of an expression consisting of the data type is a colon (:) both sides of the data type of operation is determined, and whose high accuracy, to use the data type whose
On both sides of the colon write operand data types must be able to be implicit type conversion。
(5) assignment expression
Need to pay attention to the situation: