Changes

C Sharp Looping with do and while Statements

708 bytes added, 19:26, 17 January 2008
no edit summary
<pre>
using System;
using System.Text;
 
class Hello
{
static void Main()
{
int i = 1;
 
while (i < 20)
{
i++;
if ((i % 2) != 0)
continue;
System.Console.WriteLine ("i = " + i);
}
}
}
</pre>
 
The ''continue'' statement in the above example will cause the WriteLine call to be skipped unless the value of ''i'' can be divided by 2 with no remainder. If the ''continue'' statement is triggered, execution will skip to the top of the while loop and the statements in the body of the loop will be repeated (until the value of ''i'' exceeds 19), resulting in the following output:
 
<pre>
i = 2
i = 4
i = 6
i = 8
i = 10
i = 12
i = 14
i = 16
i = 18
i = 20
</pre>