CSIT_Labs

Do while programs

As you have seen, C# supports four types of iteration statements: for, foreach, do-while, and while.

Microsoft’s language reference documentation describes these statements as follows:

The for and foreach iterations seem to be clearly differentiated from each other and from the do-while and while iterations. The definitions for the do-while and while statements, however, appear to be quite similar.

Knowing when to choose between a do-while and a while seems more arbitrary, and can even be a bit confusing. Some challenge projects may help to make the differences clear.