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
fatsuperman.
fatsuperman.2y ago
// take block of 100 out of parameters list

loop()
{
//runs multiple times
Enumerable objects = getObjects(block);
}

return objects;
//will only return last set of results

//objects
// take block of 100 out of parameters list

loop()
{
//runs multiple times
Enumerable objects = getObjects(block);
}

return objects;
//will only return last set of results

//objects
Thinker
Thinker2y ago
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.
fatsuperman.
fatsuperman.2y ago
can i also do objects = objects.concat(getObjects) ? @thinker227
Thinker
Thinker2y ago
Pretty sure, yes Although you might as well use a list
Anar
Anar2y ago
You can use linq methods like Append/Prepend/Concat. Or if it is a list Add/Insert/AddRange.
Want results from more Discord servers?
Add your server
More Posts