Please provide an working example, to use nested switch with multiple datatype?

Posted by Mahe under C# on 11/6/2012 | Points: 10 | Views : 918 | Status : [Member] | Replies : 1
Hi,

Please provide an working example, to use nested switch with multiple datatype?

string country= "India";
int countryId = 1;
ex switch(country)
{
case "India":
......
switch(countryId)
{
case 1:
...
break;
}
break;
}




Responses

Posted by: Sourabh07 on: 11/7/2012 [Member] Starter | Points: 25

Up
0
Down
hi....

please look at the following nested switch .....

Running Example:


int i = 3;

char c='c';

switch (i)
{
case 1:
Response.Write("Case 1");
break;
case 2:
Response.Write("Case 2");
break;
case 3:
switch (c)
{
case 'a':
break;
case 'c':
Response.Write("I am nested switch.");
break;
default:
Response.Write("I am default case of nested switch.");
break;
}
break;
default:
Response.Write("I am default of parent switch");
break;

}


Sourabh07

Mahe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response