Changes

Jump to: navigation, search

C Sharp Looping - The for Statement

No change in size, 16:58, 17 January 2008
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 C# provides the ''break'' statement which breaks out of the current loop and resumes execution at the code directly after the loop. For example:
<pre>

Navigation menu