❔ Foreach
in c++ i can do :
From what i know, in C# this doesn t allow me to remove, move, modify objects.
How can i do something like this
for(auto& obj : objects)
without having to use indices?5 Replies
You pretty much have to use indices
Lists specifically do not allow you to modify them during enumeration
In what way do you want to modify the object?
in any way
let s say to move it to the end
I ask this because there's several ways you could do things when it's vague, for example doing LINQ to map the list to what you want
Move the first object to the end? So you mean a
Queue<T>
would fit betterWas 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.