Why are assignment operators (=) invalid in a foreach loop? I\'m using C#, but I would assume that the argument is the same for other languages that support
The foreach is designed to interate through the array once, without repeating or skipping (though you can skip some action within the foreach construct by using the continue keyword).
If you want to modify the current item, consider using a for loop instead.