In this chapter, we took a look at some basic C# programming. Here's an overview of the topics we covered:
C# includes several iterative statements: for, while, do...while, and foreach. The first three loops—for, while, do...while—are the old standards that appear in many programming languages, but the foreach loop is something new for C++ programmers coming to C#.
The foreach loop is designed to loop over a collection, which includes arrays. This loop is useful when you want to loop over the elements in a collection, because it loops over them all automatically, without using a loop index. Loop indices, as you use with a for loop, are prone to off-by-one errors (as when you use < instead of <= in the termination expression of the loop), ...