continue statement skipping an iteration of a for statement. - CSharp Language Basics

CSharp examples for Language Basics:continue

Description

continue statement skipping an iteration of a for statement.

Demo Code

using System;//from w ww .jav  a2s  .c o m
class ContinueTest
{
   static void Main()
   {
      for (int count = 1; count <= 10; ++count) // loop 10 times
      {
         if (count == 5) // if count is 5,
         {
            continue; // skip remaining code in loop
         }
         Console.Write($"{count} ");
      }
      Console.WriteLine("\nUsed continue to skip displaying 5");
   }
}

Result


Related Tutorials