[Proposal] Add Add(IEnumerable items)
for ICollection
to support the collection initialisation syntax
#50745
Replies: 3 comments 1 reply
-
API suggestions are better made on the Runtime repository. This repository is more specifically for the C# language itself, and the language wouldn't need any changes to call an |
Beta Was this translation helpful? Give feedback.
-
Transferring this to dotnet/runtime. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Default interface methods makes modifying interface technically non-breaking, but not used in practice yet. |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to add a method
Add(IEnumerable items)
for theIList
interface?My problem is that I would like to use the collection initialisation syntax on this model (unfortunately, the IList cannot be changed to the implementation).
I have tried creating an extension method, but it seems that generic extension methods for interfaces are not accepted as valid candidates for the collection initialisation 😭
So I thought maybe it could be possible to add this method to
IList<T>
or evenICollection<T>
?Beta Was this translation helpful? Give feedback.
All reactions