What is the difference between for and foreach?
c#, for-loop, foreach
Solution
a `for` loop is a construct that says "perform this operation n. times".
a `foreach` loop is a construct that says "perform this operation against each value/object in this IEnumerable"
Problem
What is the major difference between `for` and `foreach` loops? In which scenarios can we use `for` and not `foreach` and vice versa. Would it be possible to show with a simple program? Both seem the same to me. I can't differentiate them.