Sunday, 12 May 2013

Conditional Construct in c#

 _____________________________________________
Conditional Construct:
                                                   You can use conditional construct whenever you want to check any condition or take any decision .
There are two type of conditional construct are available in c#

 1. If else Construct 

 2. Switch case construct

   If else Construct :
                                         The if else conditional construct is followed by a logical expression where data is compare and a decision is made on the basis of result of the comparison.

Syntax of If else construct:   
if (expression)
{
statement;
}
else
{
statement;
}

Switch case construct: 
                                                                       Switch case construct is used when there are multiple values for a variable.

Syntax of Switch case construct 

Switch (Variable Name)
{
case Expression 1:
statement;
break;

case Expression 2:
statement;
break

default:
statement;
break;
}

Note: The keyword switch is followed by the variable in parentheses.

switch (variable name)

case keyword is followed case keyword

case (Expression)
_______________________________________________________________________________  


No comments:

Post a Comment