Changes

Jump to: navigation, search

C Sharp Looping - The for Statement

312 bytes added, 16:28, 17 January 2008
Breaking Out of a for Loop
== Breaking Out of a for Loop ==
Having created a loop it is possible that under certain conditions you might want to break out of the loop before the completion criteria have been met (and particularly if you have created an infinite loop). One such example might involve continually checking for activity on a network socket. Once activity has been detected it will be necessary to break out of the monitoring loop and perform some other task. For the purpose of breaking out of a loop C3 provides the ''break'' statement which breaks out of the current loop and resumes execution at the code directly after the loop. For example: <pre>
== Nested for Loops ==
So far we have looked at only a single level of ''for'' loop. It is also possible to nest for loops where one for loop resides inside another for loop.

Navigation menu