For (For modes 2D, 3D, Console)
It is used when we want to repeat execution of command or block of commands and we know how many times it should repeat.
Block of commands is repeated while the condition, defined it the header of the cycle, is evaluated as true.
Syntax:
for(initialization; condition; modification) command
initialization - used to set initial state of the cycle, and is executed once when the cycle starts,
condition - is evaluated on the start of every loop, when true, the command is executed,
modification (cycle advance) - here is usually (but not necessarily) incremented (or otherwise altered) variable that is present in the condition and that is controlling the iteration.
Was this helpful?
Foreach (For modes 2D, 3D, Console)
Repeats command or block of commands for every item in array or group of objects.
Syntax:
foreach(local variable array) command
Was this helpful?
While (For modes 2D, 3D, Console)
Repeatedly executes command or block of commands while the condition defined in the header of the cycle is evaluated as true.
The condition is testes before the body of the cycle is executed. That means if the first condition evaluation is false, cycle will be executed not a single time.
Syntax:
while(condition) command
Was this helpful?
Do (For modes 2D, 3D, Console)
Repeatedly executes command or block of commands while the condition defined at the end of the cycle is evaluated as true.
It means that the body of the cycle is executed once at least.
Syntax:
do{command}while(condition)
Was this helpful?
Break (For modes 2D, 3D, Console)
You can use it to exit from inside the loop or from conditional command.
Program flow is then passed to the code following the cycle or the conditional command.
Was this helpful?
Continue (For modes 2D, 3D, Console)
It is used inside the loop for skipping the remaining commands. Program will continue from the beginning of the current loop.
Was this helpful?


Did you find this information useful?
Documentation of SGP Baltie 4 C#
Send us comments on this topic by this form ©1978-2010 SGP Systems

Parent page | Previous page | Next page