|
Delphi |
|
Break procedure immediately stops any loop execution and continues at the next statement following the loop statement:
for i:=1 to 100 do
begin
// some code here
if i=SomeMaxValue then Break;
end;
|
|
C# |
|
Like in Delphi, break used within cycle code immediately stops any loop execution and continues at the next statement following the loop statement:
for (int i = 1; i <= 100; i++)
{
if (i == SomeMaxValue) break;
...
}
Also break use for exit from switch:
switch(n)
{
case 1:
...
break;
}
|
|
|
|
|
|
|
|
|
|
Remember about break in switch. |
|
|
|
|
|
|
|
|
|
|
|