Sponsored Ad

Friday, September 25, 2009

The switch Statement in C#

The switch expression must be of an integer type, such as char, byte, short, or int, or of type string. The switch Statement is a set of if else statement .The default statement sequence is executed if no case constant matches the expression. The default is optional.If default is not present, no action takes place if all matches fail.When a match is found, the statements associated with that case are accomplished until the breach is encountered.

The general form of the switch statement is 


switch(expression) {
case constant1:
statement sequence
break;
case constant2:
statement sequence
break;
case constant3:
statement sequence
break;
.
.
.

default:
statement sequence
break;
}

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers