23
1
using System;
2
public class DoWhileLoopWithBreakExample
3
{
4
public static void Main(string[] args)
5
{
6
int i = 1;
7
8
do{
9
Console.WriteLine(i);
10
11
//check if value of i is 5
12
if(i==5)
13
{
14
//if value of i is 5, exit from loop and it will not print remaining values
15
break;
16
}
17
i++;
18
} while (i <= 10) ;
19
20
Console.Write("After loop ends");
21
22
}
23
}
Cached Result