C Sharp Programming/Keywords/break
From Wikibooks, the open-content textbooks collection
C# Programming
Cover | Introduction | Basics | Classes | The .NET Framework | Advanced Topics | Index
Cover | Introduction | Basics | Classes | The .NET Framework | Advanced Topics | Index
The keyword break is used to exit out of a loop.
int x; while( x < 20 ){ if( x > 10 ) break; x++; }
The while loop would increment x as long as it was less than twenty. However when x is incremented to ten the condition in the if statement becomes true, so the break statement causes the while loop to be broken and execution would continue after the closing parentheses.
| C# Keywords | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Special C# Identifiers | ||||||||||
|

