4 ms·
Depends what do you actually mean by sequence, but mostly purpose. Normal "for" is like: repeat this code body as long as condition is satisfied Foreach is mo
by tester756 3y ago
Depends what do you actually mean by sequence, but mostly purpose.
Normal "for" is like: repeat this code body as long as condition is satisfied
Foreach is more like: walk thru this collection
Look (c#):
foreach (var item in items) ...
for (int i=0; i<10; i++) { }
In the 2nd version it is possible to jumps ahead, back, do not move, etc. Generally play around "i's" values
Meanwhile I haven't seen yet any1 trying to do anything like this in foreach, because it is meant for just walking thru collection