Introduction to Flow of Control
In the Shakespeare.cs program presented in Chapter 2, “Your First C# Program,” all statements were executed sequentially in the order they were written in the source code. This is called sequential execution. Normally, statements in a method are executed sequentially; that is, if none of the constructs, presented in this and the next chapter that are specifically designed to redirect this otherwise linear flow of events, are encountered.
A program based purely on sequential execution will, during each execution, always perform exactly the same actions; it is unable to react in response to current conditions.
But life is seldom that simple. Often, programs need to alter the flow of control in a program.
The flow ...
Get C# Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.