You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When no dynamic expressions are involved, C# defaults to static binding, which means that the compile-time types of subexpressions are used in the selection process. However, when one of the subexpressions in the operations listed above is a dynamic expression, the operation is instead dynamically bound.
@@ -161,7 +161,7 @@ The precedence of an operator is established by the definition of its associated
161
161
> | [§12.14](expressions.md#1214-conditional-logical-operators) | Conditional OR | `\|\|` |
162
162
> | [§12.15](expressions.md#1215-the-null-coalescing-operator) and [§12.16](expressions.md#1216-the-throw-expression-operator) | Null coalescing and throw expression | `??` `throw x` |
@@ -6496,7 +6496,10 @@ The `=` operator is called the ***simple assignment operator***. It assigns the
6496
6496
6497
6497
The operator `= ref` is called the ***ref assignment operator***. It makes the right operand, which shall be a *variable_reference* ([§9.5](variables.md#95-variable-references)), the referent of the reference variable designated by the left operand. The ref assignment operator is described in [§12.21.3](expressions.md#12213-ref-assignment).
6498
6498
6499
-
The assignment operators other than the `=` and `= ref` operators are called the ***compound assignment operators***. These operators perform the indicated operation on the two operands, and then assign the resulting value to the variable, property, or indexer element given by the left operand. The compound assignment operators are described in [§12.21.4](expressions.md#12214-compound-assignment).
6499
+
The assignment operators other than the `=` and `= ref` operator are called the ***compound assignment operators***. These operators are processed as follows:
6500
+
6501
+
- For the `??=` operator, only if the value of the left-operand is `null`, is the right-operand evaluated and the result assigned to the variable, property, or indexer element given by the left operand.
6502
+
- Otherwise, the indicated operation is performed on the two operands, and then the resulting value is assigned to the variable, property, or indexer element given by the left operand. The compound assignment operators are described in [§12.21.4](expressions.md#12214-compound-assignment).
6500
6503
6501
6504
The `+=` and `-=` operators with an event access expression as the left operand are called the ***event assignment operators***. No other assignment operator is valid with an event access as the left operand. The event assignment operators are described in [§12.21.5](expressions.md#12215-event-assignment).
6502
6505
@@ -6555,7 +6558,8 @@ The run-time processing of a simple assignment of the form `x = y` with type `T`
`a??=b` isequivalentto `(T) (a?? (a=b))`, exceptthat `a` isevaluatedonlyonce, where `T` isthetypeof `a` when the type of `b` is dynamic and otherwise `T` is the type of `a ?? b`.
0 commit comments