c# - How can I use wildcards in a switch statement? -


i have switch statement uses string of 3 letters. many cases (but not all) want concern myself first 2 letters.

example, want every code begins "ff" handled same:

switch(code) {    case "ff(?)":       // handle       break;    default:       break; } 

what can here? can utilize wildcard? have consider every ff code?

for obvious reasons, don't want have code this, can grow large:

case "ffa": case "ffb": case "ffd":     // handle 

do first 2 chars @ switch, not @ case.

use default case fall 3 letter cases. it's not cleanest, work. if statements way go if switches don't cut it.

switch(code.substring(0, 2)) {     case "ff":        ...     default:         switch(code)         {             case "abc":                 ....         } } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -