Cristopher Coronado
What happens when you encounter a Continue statement inside the for loop?
By Cristopher Coronado in .NET on Aug 05 2020
  • Surendra Badireddy
    Aug, 2020 7

    If you place a continue statement inside a ‘for’ loop, then code execution will move to next iteration by skipping all the lines of code after ‘Continue’ statement.
    EX:
    for(int i=0; 1<5; i++)
    {
    if(i==3)
    {
    continue;
    }
    Console.WriteLine(i.ToString());
    }

    Output:
    1
    2
    4
    5

    Explanation: In third iteration code execution will be skipped once it enters into If condition and donot execute Console.WriteLine(i.ToString());

    • 1
  • Anchal Sikarwar
    Aug, 2020 7

    it breaks the current iteration and start next iteration. means it doesn't run code after continue and jump to the next iteration.

    • 0
  • Varun Setia
    Aug, 2020 6

    The continue statement skips the current iteration and moves to next iteration

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS