In Brief

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), ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.