|
Delphi |
|
repeat...until loop executes the code till the control condition is False. The following loop will execute until user will enter the 'exit' in the console input:
repeat
Readln(S);
// some processing of S string
until S='exit';
Important feature of repeat...until loop is checking the control condition after first iteration, so the loop code will execute at leat one time. |
|
C# |
|
do...while loop does exactly the same, but exits by the true in condition.
do
{
s = Console.ReadLine();
// some processing of s string
}
while ( s != "exit" );
|
|
|
|
|
|
|
|
|
|
Do not forget to inverse condition. |
|
|
|
|
|
|
|
|
|
|
|