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
Post a Comment