[13] Learning C # expressions, statements Comments (01)


Here Insert Picture Description

1. Definition of expression

Here Insert Picture Description

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

Here Insert Picture Description

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)
Here Insert Picture Description

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
Here Insert Picture Description

(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
Here Insert Picture Description

(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
Here Insert Picture Description

On both sides of the colon write operand data types must be able to be implicit type conversion

(5) assignment expression

Here Insert Picture Description

Need to pay attention to the situation:
Here Insert Picture Description

Published 29 original articles · won praise 3 · Views 950

Guess you like

Origin blog.csdn.net/weixin_44813932/article/details/103824440