Break and Continue in C#



The break statement can also be used to jump out of a loop

for (int i = 0; i < 10; i++)   
{  
  if (i == 7)   
  {  
    break;  
  }  
  Console.WriteLine(i);  
} 
The continue statement breaks one iteration (in the loop)
for (int i = 0; i < 10; i++)   
{  
  if (i == 7)   
  {  
    continue;  
  }  
  Console.WriteLine(i);  
}  

0 Comment's

Comment Form

Submit Comment