Proposal: allow System.Range to work with extension method Slice(this pseudoreceiver, int, int) #8805
Unanswered
orthoxerox
asked this question in
Language Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently range syntax is incompatible with types like
IReadOnlyList<T>
, because this type is countable, but doesn't have aSlice(int, int)
method.If I make an extension method
IReadOnlyList<T> Slice<T>(this IReadOnlyList<T> source, int start, int length)
, it's not recognized by the compiler as it looks for an actual instance method on the type.I propose to extend the lookup algorithm to take extension methods into account.
Alternatives:
IReadOnlyList<T>
, but this will have to be delayed until the next .Net Core release instead of a possible point release of the compiler.Beta Was this translation helpful? Give feedback.
All reactions