Paul Kahl
asked on
using an Array in a Switch Statement
I have this code:
string strSessionPageID = Session["SessionPageID"].T oString();
switch (strSessionPageID)
{
case "3":
//do x
break;
case "5":
//do y
break;
}
what I'd like to be able to do is set up arrays, and use the switch like this:
string strSessionPageID = Session["SessionPageID"].T oString();
array xArr = array("3","43","56","68");
array yArr = array("34","42","51","63") ;
switch (strSessionPageID)
{
case xArr:
//do x
break;
case yArr:
//do y
break;
}
where I use the ID in the switch, and check it against the arrays to determine the case to perform.
Is there a way to do this, and if so, might I have an example?
string strSessionPageID = Session["SessionPageID"].T
switch (strSessionPageID)
{
case "3":
//do x
break;
case "5":
//do y
break;
}
what I'd like to be able to do is set up arrays, and use the switch like this:
string strSessionPageID = Session["SessionPageID"].T
array xArr = array("3","43","56","68");
array yArr = array("34","42","51","63")
switch (strSessionPageID)
{
case xArr:
//do x
break;
case yArr:
//do y
break;
}
where I use the ID in the switch, and check it against the arrays to determine the case to perform.
Is there a way to do this, and if so, might I have an example?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER