Summary

This chapter explored the fundamental aspects of iteration and how to implement this essential programming tool by using C#'s three types of iteration statements—while, do-while, and for loops.

Important points mentioned in this chapter are reviewed in this section.

An iteration statement repeats a statement or block of statements as long as its loop condition is true.

Iteration statements are often used to generate or analyze (traverse) a sequence of data elements.

The while loop statement consists of the while keyword, a loop condition, and a loop body (consisting of one or more statements) that is repeatedly executed until the loop condition is false. The while loop is an entry condition loop, so its loop body may never be executed ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.