C# continue Statement
In C#, continue continue statement in C++ is somewhat like the break break statement. But instead of forcing termination, continue skips the code in the current loop iteration and forces the next iteration to begin.
For for a for loop, thecontinue continue statement causes the condition test and loop increment parts to execute. For a while and do...while a for loop, thecontinue while statement, it causes program control to return to the condition test.
Syntax
The syntax of the **continue ** statement in C#:
continue;
Flowchart
Example
Example
using
System
;
namespace
Loops
{
class
Program
{
static
void
Main
(
string
[
]
args
)
{
/* Local variable definition */
int
a
=
10
;
/* do loop execution */
do
{
if
(
a
==
15
)
{
/* Skip the iteration */
a
=
a
1
;
continue
;
}
Console
.
WriteLine
(
"Value of a: {0}"
, a
)
;
a
++;
}
while
(
a
<
20
);
Console
.
ReadLine
(
)
;
}
}
}
When the code above is compiled and executed, it produces the following result:
a 的值: 10
a 的值: 11
a 的值: 12
a 的值: 13
a 的值: 14
a 的值: 16
a 的值: 17
a 的值: 18
a 的值: 19
C# Loops