The continue statement in C# works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between.
For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do...while loops, continue statement causes the program control passes to the conditional tests.
Syntax:
The syntax for a continue statement in C# is as follows:
continue;
Flow Diagram:
Example:
using System; namespace Continue_Statement { class Program { static void Main(string[] args) { int i = 0; while(i<10) { i++; if (i < 6) { continue; } Console.WriteLine(i); } Console.Read(); } } }
When the above code is compiled and executed, it produces the following result:
O/P :6 7 8 9 10