continue
suggest changeIn addition to break, there is the keyword continue. Instead of leaving the loop, it skips the rest of the current iteration. That is useful when some of the loop body should not run for a particular value.
Here’s a simple example:
for (int i = 1; i <= 10; i++)
{
if (i < 9)
continue;
Console.WriteLine(i);
}
Will result in:
9
10
Note: continue is often most useful in while or do-while loops. for loops with a well-defined exit condition may not benefit as much.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents