\chapter[Control Structures\dotfill{}]{Control Structures}
\begin{paragraph}
\indent{}
Now that we can put some simple text on the screen, let's move on to
an important subject: control structures. The control structures allow
us to chose what code is executed. There are only 2 types of control
structures in C\#: the {\it if..then..else} type and the {\it switch} type.
\end{paragraph}
\section{If}
\begin{paragraph}
\indent{}
This is the basic control structure which allows conditional execution
of code . Programmers from other languages should be exceedingly familiar
with this construct \\
\end{paragraph}
\subsection{Basic IF}
\begin{paragraph}
Let's start with the basic if construct. This control structure uses an
expression and executes some code if true and some other code if
false.\\\\
The syntax of it is:
\begin{verbatim}
if(some_expression)
{
	statements.....
}
else
{
	otherwise......
}
\end{verbatim}
If the expression evaluates to true , the first block (the one under if)
is executed otherwise the second block (under else) is executed. 
\end{paragraph}
\subsection{Example: Basic If}
\begin{verbatim}
if(meaning_of_life_and_everything==42)
    {
        Console.WriteLine("By Jove it's 42 !");
    }
else
    {
        Console.WriteLine("Oh No, it's wrong !!");
    }
\end{verbatim}
\subsection{Nested If}
\begin{paragraph}
\indent{}It is also possible to nest IF statements . The following example
illustrates a nested IF statement under an ELSE of another IF..THEN..ELSE.
\end{paragraph}
\subsection{Example: Nested If}
\begin{verbatim}
if(foo == bar)
{
    //execute when foo is equal to bar
}
else
{
    if(foo == fu)
    {
        //execute when foo == fu and foo != bar
    }
    else
    {
        //execute when foo != fu and foo != bar
    }
}
\end{verbatim}
\section{Ternary Expressions}
\begin{paragraph}
\indent{}The ternary expression is a throwback from the C era of programming
and has been dutily duplicated in all its successors . The {\it ?:} expression
is a one-liner for the if then else expression. The syntax follows the
following form : {\tt CONDITION ? EXPRESSION\_TRUE : EXPRESSION\_FALSE}\\
\end{paragraph}
\subsection{Example: Ternary Expressions}
\begin{verbatim}
max = (a>b ? a : b); /// Max gets the value of the greater one of a & b
\end{verbatim}
