+ 1
how should I use the switch and what is it function
2 Answers
+ 1
if u want to check three more condition use it swtich statement eg
u having values Sunday ,Monday,Tuesday this values are stored in string
when use swtich statement if u retrieve the values Sunday mean
string Days ="Sunday";
switch(Days)
{
case "Sunday" :
console. writeline("Holiday");
break;
case "Monday":
console.writeline(" working day');
break;
............etc
this is use of switch statement
0
The switch is very similar to the if/else.
Switch to me looks prettier, but in the long runs messier.
The if/else uses mathematical operators like < > <=... While the switch only uses == by default.