Note: This already works fine, but I'm trying to understand why it works this way, but not different.
I have a WinForm (C #) with dynamically allocated images, for example: 
Now, if you click the "Invalid" button, these images should be deleted (among other things), for which I originally used:
foreach(Control ctrl in Controls) if(ctrl is PictureBox) ctrl.Dispose();
or
for(int i = 0; i < Controls.Count; i++) if(Controls[i] is PictureBox) Controls[i].Dispose();
Now, if I run this, I get:

But if I just modified the for statement to send it back, does it work ?
for(int i = Controls.Count - 1; i >= 0; i--) if(Controls[i] is PictureBox) Controls[i].Dispose();
(I will not upload another image, but it removes all the elements (I get only the buttons on the left at the end))
Can someone enlighten me why one works , but not the other ?
EDIT: I am using the VS2015 community version for Windows 10 if it is a debugging error (?)
c # for-loop winforms picturebox
NemanjaT
source share