break
It is located inside the statement. The break statement jumps out of the switch command (the code execution moves behind the switch statement).
It is located inside the cycle. The break statement terminates the cycle (the code execution is moved to behind the cycle).
var nNum = 17;
switch (nNum)
{
case 15:
Pm.Debug("case=15");
break;
case 17:
Pm.Debug("case=17");
break;
default:
Pm.Debug("switch default=" + nNum);
break;
}
var i;
for (i = 0; i <= 5; i++)
{
if (i == 3)
break;
Pm.Debug("i=" + i);
}
var i = 0;
while (i <= 5)
{
if (i == 3)
break;
Pm.Debug("i=" + i);
i++;
}
var i = 0;
do
{
if (i == 3)
break;
Pm.Debug("i=" + i);
i++;
} while (i <= 5)