Algorithm
In C#, the continue statement is used inside loops to skip the rest of the code inside the loop for the current iteration and proceed to the next iteration. It is commonly used in loops like for, while, and do-while to control the flow of execution.
Code Examples
#1 C# Programming continue with for loop
Code -
                                                        C# Programming
using System;
namespace ContinueLoop {
  class Program {
    static void Main(string[] args){
      for (int i = 1; i  < = 5; ++i{
                
        if (i == 3) {
          continue;
        }
        Console.WriteLine(i);
      }
    }
  }
}Output
2
4
5
#2 C# Programming continue with while loop
Code -
                                                        C# Programming
using System;
namespace ContinueWhile {
  class Program{
    static void Main(string[] args) {
      int i = 0;
      while (i  <  5) {
        i++;
        if (i == 3) {
          continue;
        }
        Console.WriteLine(i);
      }
    }
  }
}Output
2
4
5
#3 continue with Nested Loop in C# programming
Code -
                                                        C# Programming
using System;
namespace ContinueNested {
    class Program {
       static void Main(string[] args) {
      int sum = 0;
      // outer loop
      for(int i = 1; i  < = 3; i++) { 
      // inner loop
      for(int j = 1; j  < = 3; j++) { 
        if (j == 2) {
          continue;
        }
      Console.WriteLine("i = " + i + " j = " +j);
      }
     }
    }
   }
}Output
i = 1 j = 3
i = 2 j = 1
i = 2 j = 3
i = 3 j = 1
i = 3 j = 3
#4 C# Programming continue with foreach Loop
Code -
                                                        C# Programming
using System;
namespace ContinueForeach {
  class Program {
    static void Main(string[] args) {
      int[] num = { 1, 2, 3, 4, 5 };
      foreach(int number in num) {
        // skips the iteration
        if(number==3) {
          continue; 
         }
        Console.WriteLine(number);
      }
    }
  }
}Output
2
4
5
Demonstration
C# Programming continue Statement
