Chapter 13: Message Boxes

 

The do while Loop

The do while loop makes the test for continuance at the bottom of the loop, rather than at the top. It looks like this:

 int intCharPointer = 0; Filename.length = 4; do {   // Do something.   intCharPointer++; // Increment the CharPointer. } while(intCharPointer < Filename.Length); 

In this case, Filename is a string with four characters in it. Its char positions are numbered 0, 1, 2, and 3. The first time through the loop, char 0 is checked for something and intCharPointer is incremented to 1. The loop loops again and checks char 1; intCharPointer is incremented to 2. The loop loops again and checks char 2; intCharPointer is incremented to 3. The loop loops again and checks char 3; intCharPointer is incremented to 4, and the while test at the bottom fails.

 


Unlocking Microsoft C# V 2.0 Programming Secrets
Unlocking Microsoft C# V 2.0 Programming Secrets (Wordware Applications Library)
ISBN: 1556220979
EAN: 2147483647
Year: 2005
Pages: 129

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net