Here is some difference between 'break' and 'continue' - :
Break
Continue
Where we apply the break condition, we come to the out of the loop.
That condition in which we use the continue statement, the controller checks all conditions except that condition.
This moves the controller to the end of the loop from where it is used.
This allows the controller to check all conditions except where the statement is used.
This is done to finish the loop quickly.
It is used to jump the condition.
This prevents the repetition of the loop.
This does not prevent the repetition of the loop
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BreakAndContinue
{
class Program
{
static void Main(string[] args)
{
int a;
for (a = 1; a <= 10; a++)
{
if (a == 7)continue;
Console.WriteLine(a);
}
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BreakAndContinue
{
class Program
{
static void Main(string[] args)
{
int a;
for (a = 1; a <= 10; a++)
{
if (a == 7)break;
Console.WriteLine(a);
}
Console.ReadKey();
}
}
}
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Here is some difference between 'break' and 'continue' - :
This does not prevent the repetition of the loop