Why can't I use an OR operator in a switch case for strings in C#? -


it says cannot use or on 2 strings in switch case (dental || vision). placing each option in own separate case work or messing syntax? thanks

            switch (gr.plantypefocus){                 case "medical":                     createplanformedical();                     break;                 case "dental" || "vision":                     //createplanfordental_vision                     break;                 case "ltd" || "life":                     //createplanforltd_life                     break;             }         } 

technically achieve 'or' using fall through

switch (gr.plantypefocus){    case "medical":       createplanformedical();       break;    case "dental":    case "vision":        //createplanfordental_vision        break;     case "ltd":     case "life":        //createplanforltd_life        break;  } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -