Wednesday, May 23, 2012

C# continue Statement


C# continue Statement

The continue statement in c# is used to skip the current iteration of a loop, if a continue statement is placed in a loop then the current iteration of the loop execution is skipped on reaching the continue statement, and the loop progresses to the next iteration.

for (int i = 1; i <= 10; i++)
{
   if (i == 5)
   {
     continue;
   }
   //
   Response.Write(i.ToString() + "<br>");
}
//
Response.Write("Statement after the for Loop");

In the above example when i values is equal to 5 the continue statement is executed and the current iteration is skipped, control in transferred to the next iteration of the loop, the output in this case will be
1
2
3
4
6
7
8
9
10

Statement after the for Loop

That’s it, we have evaluated the use of the continue statement.



Related Post

Search Flipkart Products:
Flipkart.com

No comments: