IN BRIEF
In this chapter, we will explore the basic control structures provided by C#. Each of these constructs will be explored and discussed in terms of syntax and proper usage.
WHAT YOU NEED
RECOMMENDED SOFTWARE
.NET Framework Visual Studio .NET
RECOMMENDED HARDWARE
.NET-enabled desktop client
SKILLS REQUIRED
C# coding
EXPRESSIONS AND CONTROL STRUCTURES AT A GLANCE
Expressions and Control Structures
53
Basic Expressions
Legal Variable Names
Using C# Operators
54
Pre/Post Operators
60
Program Flow Control: Control Structures
The Program Execution Path
Short Circuit Evaluation
62
Conditional Statements
Using the Ternary Operator
64
The if Control Structure
61
The switch Statement
65
The if/else Control Structure Combination
Looping
68
The for Loop
The while Loop
70
Using the for Statement
The do..while Loop
72
The foreach Statement
69