-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
📌 seQUESTeredIdentifies that an issue has been imported into Quest.Identifies that an issue has been imported into Quest.dotnet-csharp/svcin-prThis issue will be closed (fixed) by an active pull request.This issue will be closed (fixed) by an active pull request.lang-reference/subsvc
Description
Type of issue
Missing information
Description
Overload resolution can product different results when an argument to a params
parameter is a set of discrete elements vs. a collection, especially a collection expression.
Consider:
static void M(int[] p1, params int[] p2) {} // overload 1
static void M((Span<object> p1, params ReadOnlySpan<int> p2) {} // overload 2
M([1], 2); // picks overload 1 int[] is better for p1, neither better for p2
M([1], [2]); // ambiguous int[] is better for p1, ReadOnlySpan<int> is better for p2
In this case, the conversion from collection expression is better for ReadOnlySpan
. However, the same situation occurs if the second parameter were an array of int
: That's an identity conversion.
Page URL
Content source URL
Document Version Independent Id
7241f712-8d73-b5e0-37c0-5f05c92412c6
Article author
Metadata
- ID: b8dd92fe-5053-1bc6-1c8f-cf9f88635cb5
- Service: dotnet-csharp
- Sub-service: lang-reference
Metadata
Metadata
Assignees
Labels
📌 seQUESTeredIdentifies that an issue has been imported into Quest.Identifies that an issue has been imported into Quest.dotnet-csharp/svcin-prThis issue will be closed (fixed) by an active pull request.This issue will be closed (fixed) by an active pull request.lang-reference/subsvc