How to use continue statement to exit a for statement iteration

using System;
 
public class ContinueBreakIterate
{
   public static void Main( string[] args )
   {
      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( "{0} ", count );
      } // end for
 
      Console.WriteLine( "\nUsed continue to skip displaying 5" );
   } // end Main
} // end class ContinueBreakIterate

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.