From 2d971054ca01cb55b9305c3b6b74d3792ab180a7 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Wed, 9 Oct 2024 11:45:36 -0400 Subject: [PATCH] Explain better conversion from collection expression (#42995) * Explain better conversion from collection expression Fixes #42819 * fix warnings from C# standard update We merged part of NRT into the C# standard repo. Fix the ripple effects of renumbering sections. --- .../language-reference/operators/arithmetic-operators.md | 4 ++-- .../language-reference/operators/collection-expressions.md | 1 + docs/csharp/language-reference/operators/default.md | 2 +- .../language-reference/operators/member-access-operators.md | 4 ++-- docs/csharp/language-reference/operators/nameof.md | 2 +- docs/csharp/language-reference/operators/new-operator.md | 2 +- .../language-reference/operators/type-testing-and-cast.md | 2 +- .../language-reference/statements/checked-and-unchecked.md | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/csharp/language-reference/operators/arithmetic-operators.md b/docs/csharp/language-reference/operators/arithmetic-operators.md index ae08b6779461d..a581621cff764 100644 --- a/docs/csharp/language-reference/operators/arithmetic-operators.md +++ b/docs/csharp/language-reference/operators/arithmetic-operators.md @@ -277,7 +277,7 @@ You can use the `checked` modifier only when you overload any of the following o For more information, see the following sections of the [C# language specification](~/_csharpstandard/standard/README.md): -- [Postfix increment and decrement operators](~/_csharpstandard/standard/expressions.md#12815-postfix-increment-and-decrement-operators) +- [Postfix increment and decrement operators](~/_csharpstandard/standard/expressions.md#12816-postfix-increment-and-decrement-operators) - [Prefix increment and decrement operators](~/_csharpstandard/standard/expressions.md#1296-prefix-increment-and-decrement-operators) - [Unary plus operator](~/_csharpstandard/standard/expressions.md#1292-unary-plus-operator) - [Unary minus operator](~/_csharpstandard/standard/expressions.md#1293-unary-minus-operator) @@ -287,7 +287,7 @@ For more information, see the following sections of the [C# language specificati - [Addition operator](~/_csharpstandard/standard/expressions.md#12105-addition-operator) - [Subtraction operator](~/_csharpstandard/standard/expressions.md#12106-subtraction-operator) - [Compound assignment](~/_csharpstandard/standard/expressions.md#12214-compound-assignment) -- [The checked and unchecked operators](~/_csharpstandard/standard/expressions.md#12819-the-checked-and-unchecked-operators) +- [The checked and unchecked operators](~/_csharpstandard/standard/expressions.md#12820-the-checked-and-unchecked-operators) - [Numeric promotions](~/_csharpstandard/standard/expressions.md#1247-numeric-promotions) ## See also diff --git a/docs/csharp/language-reference/operators/collection-expressions.md b/docs/csharp/language-reference/operators/collection-expressions.md index 5b3e3297af5b2..353497c1d85b3 100644 --- a/docs/csharp/language-reference/operators/collection-expressions.md +++ b/docs/csharp/language-reference/operators/collection-expressions.md @@ -53,6 +53,7 @@ The compiler uses static analysis to determine the most performant way to create Many APIs are overloaded with multiple collection types as parameters. Because a collection expression can be converted to many different expression types, these APIs might require casts on the collection expression to specify the correct conversion. The following conversion rules resolve some of the ambiguities: +- A better element conversion is preferred over a better collection type conversion. In other words, the type of elements in the collection expression has more importance than the type of the collection. These rules are described in the feature spec for [better conversion from collection expression](~/_csharplang/proposals/csharp-13.0/collection-expressions-better-conversion.md). - Conversion to , , or another [`ref struct`](../builtin-types/ref-struct.md) type is better than a conversion to a non-ref struct type. - Conversion to a noninterface type is better than a conversion to an interface type. diff --git a/docs/csharp/language-reference/operators/default.md b/docs/csharp/language-reference/operators/default.md index a1d5bcc4283e7..ae14db471782c 100644 --- a/docs/csharp/language-reference/operators/default.md +++ b/docs/csharp/language-reference/operators/default.md @@ -37,7 +37,7 @@ The following example shows the usage of the `default` literal: ## C# language specification -For more information, see the [Default value expressions](~/_csharpstandard/standard/expressions.md#12820-default-value-expressions) section of the [C# language specification](~/_csharpstandard/standard/README.md). +For more information, see the [Default value expressions](~/_csharpstandard/standard/expressions.md#12821-default-value-expressions) section of the [C# language specification](~/_csharpstandard/standard/README.md). ## See also diff --git a/docs/csharp/language-reference/operators/member-access-operators.md b/docs/csharp/language-reference/operators/member-access-operators.md index 1198a7b66cf31..93f2983fc6da5 100644 --- a/docs/csharp/language-reference/operators/member-access-operators.md +++ b/docs/csharp/language-reference/operators/member-access-operators.md @@ -250,9 +250,9 @@ The `.`, `()`, `^`, and `..` operators can't be overloaded. The `[]` operator is For more information, see the following sections of the [C# language specification](~/_csharpstandard/standard/README.md): - [Member access](~/_csharpstandard/standard/expressions.md#1287-member-access) -- [Element access](~/_csharpstandard/standard/expressions.md#12811-element-access) +- [Element access](~/_csharpstandard/standard/expressions.md#12812-element-access) - [Null-conditional member access](~/_csharpstandard/standard/expressions.md#1288-null-conditional-member-access) -- [Invocation expressions](~/_csharpstandard/standard/expressions.md#1289-invocation-expressions) +- [Invocation expressions](~/_csharpstandard/standard/expressions.md#12810-invocation-expressions) For more information about indices and ranges, see the [feature proposal note](~/_csharplang/proposals/csharp-8.0/ranges.md). diff --git a/docs/csharp/language-reference/operators/nameof.md b/docs/csharp/language-reference/operators/nameof.md index 5efb63c4a779d..3893a6b4e7146 100644 --- a/docs/csharp/language-reference/operators/nameof.md +++ b/docs/csharp/language-reference/operators/nameof.md @@ -32,7 +32,7 @@ When the operand is a [verbatim identifier](../tokens/verbatim.md), the `@` char ## C# language specification -For more information, see the [Nameof expressions](~/_csharpstandard/standard/expressions.md#12822-the-nameof-operator) section of the [C# language specification](~/_csharpstandard/standard/README.md), and the [C# 11 - Extended `nameof` scope](~/_csharplang/proposals/csharp-11.0/extended-nameof-scope.md) feature specification. +For more information, see the [Nameof expressions](~/_csharpstandard/standard/expressions.md#12823-the-nameof-operator) section of the [C# language specification](~/_csharpstandard/standard/README.md), and the [C# 11 - Extended `nameof` scope](~/_csharplang/proposals/csharp-11.0/extended-nameof-scope.md) feature specification. ## See also diff --git a/docs/csharp/language-reference/operators/new-operator.md b/docs/csharp/language-reference/operators/new-operator.md index a3c575b51fd78..8a4a2f210a995 100644 --- a/docs/csharp/language-reference/operators/new-operator.md +++ b/docs/csharp/language-reference/operators/new-operator.md @@ -62,7 +62,7 @@ A user-defined type can't overload the `new` operator. ## C# language specification -For more information, see [The new operator](~/_csharpstandard/standard/expressions.md#12816-the-new-operator) section of the [C# language specification](~/_csharpstandard/standard/README.md). +For more information, see [The new operator](~/_csharpstandard/standard/expressions.md#12817-the-new-operator) section of the [C# language specification](~/_csharpstandard/standard/README.md). For more information about a target-typed `new` expression, see the [feature proposal note](~/_csharplang/proposals/csharp-9.0/target-typed-new.md). diff --git a/docs/csharp/language-reference/operators/type-testing-and-cast.md b/docs/csharp/language-reference/operators/type-testing-and-cast.md index 435352367e278..4984c47536569 100644 --- a/docs/csharp/language-reference/operators/type-testing-and-cast.md +++ b/docs/csharp/language-reference/operators/type-testing-and-cast.md @@ -148,7 +148,7 @@ For more information, see the following sections of the [C# language specificati - [The is operator](~/_csharpstandard/standard/expressions.md#121212-the-is-operator) - [The as operator](~/_csharpstandard/standard/expressions.md#121213-the-as-operator) - [Cast expressions](~/_csharpstandard/standard/expressions.md#1297-cast-expressions) -- [The typeof operator](~/_csharpstandard/standard/expressions.md#12817-the-typeof-operator) +- [The typeof operator](~/_csharpstandard/standard/expressions.md#12818-the-typeof-operator) ## See also diff --git a/docs/csharp/language-reference/statements/checked-and-unchecked.md b/docs/csharp/language-reference/statements/checked-and-unchecked.md index 846b42e2f3d64..ec5fd964156e6 100644 --- a/docs/csharp/language-reference/statements/checked-and-unchecked.md +++ b/docs/csharp/language-reference/statements/checked-and-unchecked.md @@ -55,7 +55,7 @@ Constant expressions are evaluated by default in a checked context and a compile For more information, see the following sections of the [C# language specification](~/_csharpstandard/standard/README.md): - [The checked and unchecked statements](~/_csharpstandard/standard/statements.md#1312-the-checked-and-unchecked-statements) -- [The checked and unchecked operators](~/_csharpstandard/standard/expressions.md#12819-the-checked-and-unchecked-operators) +- [The checked and unchecked operators](~/_csharpstandard/standard/expressions.md#12820-the-checked-and-unchecked-operators) - [User-defined checked and unchecked operators - C# 11](~/_csharplang/proposals/csharp-11.0/checked-user-defined-operators.md) ## See also