While loop

suggest change
int n = 0;
while (n < 5) 
{
    Console.WriteLine(n);
    n++;
}

Output:

0 1 2 3 4

IEnumerators can be iterated with a while loop:

// Call a custom method that takes a count, and returns an IEnumerator for a list
// of strings with the names of theh largest city metro areas.
IEnumerator<string> largestMetroAreas = GetLargestMetroAreas(4);

while (largestMetroAreas.MoveNext())
{
    Console.WriteLine(largestMetroAreas.Current);
}

Sample output:

Tokyo/Yokohama New York Metro Sao Paulo Seoul/Incheon

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Looping:
* break
* While loop

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script