Hi Guys,
I have a problem with selecting several item from a combobox which are suppose to call same method. let's say I have a combobox populated like this list
One
Two
Three
Four
Five
Six

Now I would like to let if user select one of these three option "One","Two","Five" from the list the ThisMethod(); has been called and so on. But as you know we can not pass more than one item trough Equals().

if (comblist.SelectedItem.ToString().Equals("One","Two","Five"))
{
//Do  ThisMethod();
}
else{
//Do ThatMethod();

I also tried to create an array like

private string[] sserver = {"One","Two","Five"};
if (comblist.SelectedItem.ToString().Equals(sserver.ToString()))
{
//Do  ThisMethod();
}
else{
//Do ThatMethod();

But this one didn't go trough, neither.
Can you please let me know how I can fix it?
Thanks for your time

Please Guys!
Some body help me!

switch (Comblist.SelectedItem.ToString()) {
    case "One" :
    case "Two" :
    case "Five" :
        DoSomeMethod();
        break;
    case "Three" :
        DoSecondMethod();
        break;
    default:
        DoLastMethod();
        break;
}

Thanks Momerath,
Just as always it was perfect and to be honest I was always thinking what is the use of the Switch in programming and this was like a rock I really enjoyed that
Thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.