YouTip LogoYouTip

Csharp Continue Statement

# C# continue Statement [![Image 4: C# Loops](#) C# Loops](#) The **continue** statement in C# is somewhat similar to the **break** statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between. For **for** loops, the **continue** statement causes the conditional test and increment portions of the loop to execute. For **while** and **do...while** loops, **continue** statement causes the program control to pass to the conditional tests. ## Syntax The syntax of a **continue** statement in C# is: continue; ## Flowchart ![Image 5: continue statement in C#](#) ## 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("a value: {0}", a); a++; }while(a <20); Console.ReadLine(); } } } When the above code is compiled and executed, it produces the following result: a value: 10 a value: 11 a value: 12 a value: 13 a value: 14 a value: 16 a value: 17 a value: 18 a value: 19 [![Image 6: C# Loops](#) C# Loops](#)
← Csharp EncapsulationCsharp Break Statement β†’