Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

easy (hopefully) c# switch question

  Asked By: Harry    Date: Mar 26    Category: Asp.net    Views: 641
  

Is anyone aware if it's possible to claim multiple case statements in a
switch in c#? i'd like to do something like:


switch(strX)
{
case "one", "two":
blah;
break;
default:
break;
}

...so if strX = "one" or "two" then blah would be executed.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Troy Kelley     Answered On: Mar 26



try this.
switch(strX)
{
case "one":
case "two": blah; break;
default:
break;
}

 
Didn't find what you were looking for? Find more on easy (hopefully) c# switch question Or get search suggestion and latest updates.




Tagged: