c# - Switch case with Boolean -
i trying create prefix text value project. using switch case that. when user select relevant radio button should give prefix value.
what should give after "switch ()"
the value coming user selection boolean value. output string.
any help..
public string officepostfix() { string postfix = null; switch (...) { case sheetmgrform.goldcoast = true: postfix = "qld"; break; case sheetmgrform.melbourne = true: postfix = "mel"; break; case sheetmgrform.sydney = true: postfix = "syd"; break; case sheetmgrform.brisbane = true: postfix = "bis"; break; } return postfix; }
that's not how switch
works. can't put arbitrary boolean expression in each case
(assuming mean ==
, not =
, btw).
you need use set of if-else
blocks, like:
if (sheetmgrform.goldcoast) { postfix = "qld"; } else if (sheetmgrform.melbourne) { postfix = "mel"; } else if ......
however, looks design use rework. having separate booleans clumsy.
Comments
Post a Comment