31 lines
531 B
Markdown
31 lines
531 B
Markdown
---
|
|
title: Continue statement
|
|
---
|
|
|
|
# Continue statement
|
|
|
|
The `continue` statement passes control to the next iteration inside a loop.
|
|
|
|
In this example, when the value of i is 2, the next statement within the loop is skipped.
|
|
|
|
## Example
|
|
```
|
|
int[] array = { 1, 2, 3, 4, 5 };
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
if( i == 2)
|
|
{
|
|
continue;
|
|
}
|
|
Console.WriteLine("Item on index {0} is {1}", i, array[i]);
|
|
}
|
|
```
|
|
|
|
## Output:
|
|
```
|
|
> Item on index 0 is 1
|
|
> Item on index 1 is 2
|
|
> Item on index 3 is 4
|
|
> Item on index 4 is 5
|
|
```
|