Skip to content
June 23, 2009 / kiranpatils

Can I have a Switch Statement with more than one Case Criteria?

Challenge:

How can i put more than one criteria for switch case??…I would like to achieve the below things:

if((condition1 == true) || (condition2 == true))
 {

 //I am inside..

}

How to do this with switch? Here is the way…

Solution:

//For C# Champs
switch (Nationality)
{
case "Indian":
case "Ind":
//Hey i am Indian
break;
}
‘For VB Champs
Select Case temp
 Case "Indian", "Ind"
 'Hey i am Indian
 Exit Select
End Select

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: