Continue statement
When processing data in a loop, you sometimes do not want to process every single item. With the continue
statement you can skip the current iteration of a loop and proceed with the next. This example uses the continue
statement to ignore all elements in an IntArray
that are equal to zero:
void ProcessNonZero(IntArray data)
{
int entries = Count(data);
int i = 0;
while (i < entries)
{
if (data[i] == 0)
{
i = i + 1;
continue;
}
WriteLine(data[i]);
i = i + 1;
}
}