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
- `V` isoneof `IEnumerable<V₁>`, `ICollection<V₁>`, `IReadOnlyList<V₁>>`, `IReadOnlyCollection<V₁>` or `IList<V₁>` and `U` isasingle-dimensionalarraytype `U₁[]`
844
844
- `V` isaconstructed `class`, `struct`, `interface` or `delegate` type `C<V₁...Vₑ>` and there is a unique type `C<U₁...Uₑ>` such that `U` (or, if `U` isa type `parameter`, itseffectivebaseclassoranymemberofitseffectiveinterfaceset) is identical to, `inherits` from (directlyorindirectly), orimplements (directlyorindirectly) `C<U₁...Uₑ>`.
845
-
- (The “uniqueness” restrictionmeansthatinthecaseinterface `C<T>{} classU: C<X>, C<Y>{}`, thennoinferenceismade when inferring from `U` to `C<T>` because `U₁` could be `X` or `Y`.)
845
+
- (The “uniqueness” restrictionmeansthatinthecaseinterface `C<T>{} classU: C<X>, C<Y>{}`, thennoinferenceismade when inferring from `U` to `C<T>` because `U₁` could be `X` or `Y`.)
- Otherwise, if `U` isanarraytypethena *lower-boundinference* ismade
@@ -862,7 +862,7 @@ An *upper-bound inference from* a type `U` *to* a type `V` is made as follows:
862
862
- `U` isoneof `IEnumerable<Uₑ>`, `ICollection<Uₑ>`, `IReadOnlyList<Uₑ>`, `IReadOnlyCollection<Uₑ>` or `IList<Uₑ>` and `V` isasingle-dimensionalarraytype `Vₑ[]`
863
863
- `U` isthetype `U1?` and `V` isthetype `V1?`
864
864
- `U` isconstructedclass, struct, interfaceordelegate type `C<U₁...Uₑ>` and `V` is a `class, struct, interface` or `delegate` type which is `identical` to, `inherits` from (directlyorindirectly), orimplements (directlyorindirectly) auniquetype `C<V₁...Vₑ>`
865
-
- (The “uniqueness” restrictionmeansthatgivenaninterface `C<T>{} classV<Z>:C<X<Z>>, C<Y<Z>>{}`, thennoinferenceismade when inferring from `C<U₁>` to `V<Q>`. Inferences are not made from `U₁` to either `X<Q>` or `Y<Q>`.)
865
+
- (The “uniqueness” restrictionmeansthatgivenaninterface `C<T>{} classV<Z>:C<X<Z>>, C<Y<Z>>{}`, thennoinferenceismade when inferring from `C<U₁>` to `V<Q>`. Inferences are not made from `U₁` to either `X<Q>` or `Y<Q>`.)
@@ -1571,7 +1571,7 @@ A *simple_name* is either of the form `I` or of the form `I<A₁, ..., Aₑ>`,
1571
1571
- Otherwise, if the location where the *simple_name* occurs is enclosed by a namespace declaration for `N`:
1572
1572
- If `e` is zero and the namespace declaration contains an *extern_alias_directive* or *using_alias_directive* that associates the name `I` with an imported namespace or type, then the *simple_name* refers to that namespace or type.
1573
1573
- Otherwise, if the namespaces imported by the *using_namespace_directive*s of the namespace declaration contain exactly one type having name `I` and `e` type parameters, then the *simple_name* refers to that type constructed with the given type arguments.
1574
-
- Otherwise, if the namespaces imported by the *using_namespace_directive*s of the namespace declaration contain more than one type having name `I` and `e` type parameters, then the *simple_name* is ambiguous and a compile-time error occurs.
1574
+
- Otherwise, if the namespaces imported by the *using_namespace_directive*s of the namespace declaration contain more than one type having name `I` and `e` type parameters, then the *simple_name* is ambiguous and a compile-time error occurs.
1575
1575
> *Note*: This entire step is exactly parallel to the corresponding step in the processing of a *namespace_or_type_name* ([§7.8](basic-concepts.md#78-namespace-and-type-names)). *end note*
1576
1576
- Otherwise, if `e` is zero and `I` is the identifier `_`, the *simple_name* is a *simple discard*, which is a form of declaration expression ([§12.19](expressions.md#1219-declaration-expressions)).
1577
1577
- Otherwise, the *simple_name* is undefined and a compile-time error occurs.
@@ -1596,7 +1596,7 @@ A *tuple_literal* represents a tuple, and consists of two or more comma-separate
1596
1596
tuple_literal
1597
1597
: '(' tuple_element (',' tuple_element)+ ')'
1598
1598
;
1599
-
1599
+
1600
1600
tuple_element
1601
1601
: (identifier ':')? expression
1602
1602
;
@@ -1675,7 +1675,7 @@ The *member_access* is evaluated and classified as follows:
1675
1675
1676
1676
- If `e` is zero and `E` is a namespace and `E` contains a nested namespace with name `I`, then the result is that namespace.
1677
1677
- Otherwise, if `E` is a namespace and `E` contains an accessible type having name `I` and `K` type parameters, then the result is that type constructed with the given type arguments.
1678
-
- If `E` is classified as a type, if `E` is not a type parameter, and if a member lookup ([§12.5](expressions.md#125-member-lookup)) of `I` in `E` with `K` type parameters produces a match, then `E.I` is evaluated and classified as follows:
1678
+
- If `E` is classified as a type, if `E` is not a type parameter, and if a member lookup ([§12.5](expressions.md#125-member-lookup)) of `I` in `E` with `K` type parameters produces a match, then `E.I` is evaluated and classified as follows:
1679
1679
> *Note*: When the result of such a member lookup is a method group and `K` is zero, the method group can contain methods having type parameters. This allows such methods to be considered for type argument inferencing. *end note*
1680
1680
- If `I` identifies a type, then the result is that type constructed with any given type arguments.
1681
1681
- If `I` identifies one or more methods, then the result is a method group with no associated instance expression.
-If `T` isanon-nullablevaluetype, thenthetypeof `E` is `T?`, andthemeaningof `E` isthesameasthemeaningof:
2391
2391
@@ -3606,27 +3606,27 @@ For an operation of the form `–x`, unary operator overload resolution ([§12.
3606
3606
```csharp
3607
3607
intoperator –(intx);
3608
3608
longoperator –(longx);
3609
-
```
3609
+
```
3610
3610
3611
3611
The result is computed by subtracting `X` from zero. If the value of `X` is the smallest representable value of the operand type (−2³¹ for `int` or −2⁶³ for `long`), then the mathematical negation of `X` is not representable within the operand type. If this occurs within a `checked` context, a `System.OverflowException` is thrown; if it occurs within an `unchecked` context, the result is the value of the operand and the overflow is not reported.
3612
-
3612
+
3613
3613
If the operand of the negation operator is of type `uint`, it is converted to type `long`, and the type of the result is `long`. An exception is the rule that permits the `int` value `−2147483648` (−2³¹) to be written as a decimal integer literal ([§6.4.5.3](lexical-structure.md#6453-integer-literals)).
3614
-
3614
+
3615
3615
If the operand of the negation operator is of type `ulong`, a compile-time error occurs. An exception is the rule that permits the `long` value `−9223372036854775808` (−2⁶³) to be written as a decimal integer literal ([§6.4.5.3](lexical-structure.md#6453-integer-literals))
3616
3616
- Floating-point negation:
3617
3617
3618
3618
```csharp
3619
3619
floatoperator –(floatx);
3620
3620
doubleoperator –(doublex);
3621
3621
```
3622
-
3622
+
3623
3623
The result is the value of `X` with its sign inverted. If `x` is `NaN`, the result is also `NaN`.
3624
3624
- Decimal negation:
3625
3625
3626
3626
```csharp
3627
3627
decimaloperator –(decimalx);
3628
3628
```
3629
-
3629
+
3630
3630
The result is computed by subtracting `X` from zero. Decimal negation is equivalent to using the unary minus operator of type `System.Decimal`.
3631
3631
3632
3632
Lifted ([§12.4.8](expressions.md#1248-lifted-operators)) forms of the unlifted predefined unary minus operators defined above are also predefined.
@@ -3886,9 +3886,14 @@ If a switch expression is not subject to a *switch expression conversion*, then
3886
3886
3887
3887
It is an error if some *switch_expression_arm*’s pattern cannot affect the result because some previous pattern and guard will always match.
3888
3888
3889
-
A switch expression is said to be *exhaustive* if every value of its input is handled by at least one arm of the switch expression. The compiler shall produce a warning if a switch expression is not exhaustive.
3889
+
A switch expression is *exhaustive* if every value of its input is handled by at least one arm of the switch expression. A warning may be issued if a switch expression is not exhaustive.
3890
+
3890
3891
At runtime, the result of the *switch_expression* is the value of the *expression* of the first *switch_expression_arm* for which the expression on the left-hand-side of the *switch_expression* matches the *switch_expression_arm*’s pattern, and for which the *case_guard* of the *switch_expression_arm*, if present, evaluates to `true`. If there is no such *switch_expression_arm*, the *switch_expression* throws an instance of the exception `System.InvalidOperationException` (or a class derived from that).
3891
3892
3893
+
> *Note*: A corollary of the above is that a *switch_expression* with no *switch_expression_arms* will produce a compile time warning, and if evaluated at runtime will always throw an exception. *end note*
3894
+
<!-- markdownlint-disable MD028 -->
3895
+
3896
+
<!-- markdownlint-enable MD028 -->
3892
3897
> *Example*: The following converts values of an enum representing visual directions on an online map to the corresponding cardinal directions:
@@ -3968,7 +3973,7 @@ The predefined multiplication operators are listed below. The operators all comp
3968
3973
```
3969
3974
3970
3975
The product is computed according to the rules of IEC 60559 arithmetic. The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaNs. In the table, `x` and `y` are positive finite values. `z` is the result of `x * y`, rounded to the nearest representable value. If the magnitude of the result is too large for the destination type, `z` is infinity. Because of rounding, `z` may be zero even though neither `x` nor `y` is zero.
@@ -4056,7 +4061,7 @@ The predefined remainder operators are listed below. The operators all compute t
4056
4061
longoperator%(longx, longy);
4057
4062
ulongoperator%(ulongx, ulongy);
4058
4063
```
4059
-
4064
+
4060
4065
The result of `x % y` is the value produced by `x – (x / y) * y`. If `y` is zero, a `System.DivideByZeroException` is thrown.
4061
4066
4062
4067
If the left operand is the smallest `int` or `long` value and the right operand is `–1`, a `System.OverflowException` is thrown if and only if `x / y` would throw an exception.
@@ -4066,7 +4071,7 @@ The predefined remainder operators are listed below. The operators all compute t
4066
4071
floatoperator%(floatx, floaty);
4067
4072
doubleoperator%(doublex, doubley);
4068
4073
```
4069
-
4074
+
4070
4075
The following table lists the results of all possible combinations of nonzero finite values, zeros, infinities, and NaNs. In the table, `x` and `y` are positive finite values. `z` is the result of `x % y` and is computed as `x – n * y`, where n is the largest possible integer that is less than or equal to `x / y`. This method of computing the remainder is analogous to that used for integer operands, but differs from the IEC 60559 definition (in which `n` is the integer closest to `x / y`).
@@ -4086,7 +4091,7 @@ The predefined remainder operators are listed below. The operators all compute t
4086
4091
```
4087
4092
4088
4093
If the value of the right operand is zero, a `System.DivideByZeroException` is thrown. It is implementation-defined when a `System.ArithmeticException` (or a subclass thereof) is thrown. A conforming implementation shall not throw an exception for `x % y` in any case where `x / y` does not throw an exception. The scale of the result, before any rounding, is the larger of the scales of the two operands, and the sign of the result, if non-zero, is the same as that of `x`.
4089
-
4094
+
4090
4095
Decimal remainder is equivalent to using the remainder operator of type `System.Decimal`.
4091
4096
> *Note*: These rules ensure that for all types, the result never has the opposite sign of the left operand. *end note*
4092
4097
@@ -4126,7 +4131,7 @@ The predefined addition operators are listed below. For numeric and enumeration
4126
4131
|**`+∞`**|`+∞`|`+∞`|`+∞`|`+∞`|`NaN`|`NaN`|
4127
4132
|**`-∞`**|`-∞`|`-∞`|`-∞`|`NaN`|`-∞`|`NaN`|
4128
4133
|**`NaN`**|`NaN`|`NaN`|`NaN`|`NaN`|`NaN`|`NaN`|
4129
-
4134
+
4130
4135
- Decimal addition:
4131
4136
4132
4137
```csharp
@@ -4153,7 +4158,7 @@ The predefined addition operators are listed below. For numeric and enumeration
4153
4158
```
4154
4159
4155
4160
These overloads of the binary `+` operator perform string concatenation. If an operand of string concatenation is `null`, an empty string is substituted. Otherwise, any non-`string` operand is converted to its string representation by invoking the virtual `ToString` method inherited from type `object`. If `ToString` returns `null`, an empty string is substituted.
(Intheabovetable, the `-y` entriesdenotethe*negation*of `y`, notthatthevalueisnegative.)
4232
4237
-Decimalsubtraction:
4233
4238
@@ -4773,9 +4778,7 @@ The operation `E is T` is evaluated as follows:
4773
4778
1. If `E` is the `null` literal, or if the value of `E` is `null`, the result is `false`.
4774
4779
1. Otherwise:
4775
4780
1. Let `R` be the runtime type of `E`.
4776
-
1. Let `D` be derived from `R` as follows:
4777
-
1. If `R` is a nullable value type, `D` is the underlying type of `R`.
4778
-
1. Otherwise, `D` is `R`.
4781
+
1. Determine the type `D`. If `R` is a nullable value type, `D` is its underlying type; otherwise, `D` is equal to `R`.
4779
4782
1. The result depends on `D` and `T` as follows:
4780
4783
1. If `T` is a reference type, the result is `true` if:
4781
4784
- an identity conversion exists between `D` and `T`, or
@@ -4811,7 +4814,7 @@ For an expression of the form `E is P`, where `E` is a relational expression of
4811
4814
-`E` does not designate a value or does not have a type.
4812
4815
- The pattern `P` is not applicable ([§11.2](patterns.md#112-pattern-forms)) to the type `T`.
4813
4816
4814
-
Every *single_variable_designation* of the pattern introduces a new local variable that is *definitely assigned* ([§9.4](variables.md#94-definite-assignment)) when the corresponding *relational_expression* tests `true`.
4817
+
Every *single_variable_designation* of the pattern introduces a new local variable that is *definitely assigned* ([§9.4](variables.md#94-definite-assignment)) when the corresponding *relational_expression* tests `true` ([§9.4.4.34](variables.md#94434-is-pattern-expressions)).
0 commit comments