C#C
C#3y ago
Sound

❔ Foreach

in c++ i can do :
auto objects = std::vector<Object>();
for(auto& obj : objects) {...} // here i can modify obj (move, remove etc)
for(auto obj : objects) {...} // here i can't move/delete obj from objects


From what i know, in C# this doesn t allow me to remove, move, modify objects.
var objects = new List<Object>();
foreach(var obj in objects) {...}


How can i do something like this for(auto& obj : objects) without having to use indices?
Was this page helpful?