Enumerable merging with Enumerable
Hello I have a function getObjects() and I have a large parameters list that I have to pass in blocks into this function in a loop. I have an Enumerable objects and if I run the loop the objects enumerable will be equal to the last result of the function, but I want it to be an Enumerable of all results of the loop. How to handle this?
5 Replies
You can use a list and add the objects to every iteration.
Or depending on what you're doing, you could use
.SelectMany
to perform GetObjects
on every item and then merge that into a single sequence.can i also do objects = objects.concat(getObjects) ? @thinker227
Pretty sure, yes
Although you might as well use a list
You can use linq methods like
Append
/Prepend
/Concat
.
Or if it is a list Add
/Insert
/AddRange
.