❔ Create list from items and other lists
Whats the best way to create a new list that combines an item A, an item B, and a list C?
11 Replies
something like?
you could use the
.Concat
extension method on the list
C.Concat(new [] { A, B })
but if your goal is a new list then just copy the list and add the items
I guess I should have clarified the order matters
then
gotcha
I often try to write my code in a way that declaration and assignment all happens in a single line
I think in javascript you can do new [a, b, ...c], was hoping there was something similar in c#
nope, no spread operator in C#
gotcha. thank you 🙂
spread operator is just sugar to what
AddRange
would be in c#basically
there's just no one-liner for this specific application
coming soon™!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.