C# program to demonstrate the use of break statement
Program.cs
for (int i = 0; i < 10; i++)
{
    if (i == 5)
    {
        break;
    }
    Console.WriteLine(i);
}
Output
kodingwindow@kw:~/csharp$ dotnet run
0
1
2
3
4
kodingwindow@kw:~/csharp$ 
C# program to demonstrate the use of continue statement
Program.cs
for (int i = 0; i < 10; i++)
{
    if (i == 5)
    {
        continue;
    }
    Console.WriteLine(i);
}
Output
kodingwindow@kw:~/csharp$ dotnet run
0
1
2
3
4
6
7
8
9
kodingwindow@kw:~/csharp$ 
What Next?
C# Loops
Advertisement