Skip to main content

Notifications

Dynamics 365 Community / Blogs / DaxGeek / Continue and Break Statements

Continue and Break Statements

You can use continue and break statements within all three loops to tell the
execution to break or continue.
The
break statement completely interrupts a loop at any time. The best example
of a
break is in a switch statement.
The continue statement ignores the rest of the current loop and continues to
control the loop. The following example uses a
for loop with the continuestatement to control which values print to the screen. The loop executes the print
statement for values <= 3 and >= 8.
int counter;
for (counter=1;counter <= 10;counter++)
{
if (counter > 3 && counter < 8)
{
continue;
}
print counter;
}
pause;
Result:
1
2
3
8
9
10


Best Regards,
Hossein Karimi

Comments

*This post is locked for comments