[Solved] Why can’t you modify a collection in a for each loop


The Best answer would be that List has some kind of Tracking over its list items and can update its items as you ask but a simple IEnumerable does not so it will not allow you to change them.

solved Why can’t you modify a collection in a for each loop