(not sure if title explains the matter well enough)
I have this piece of code:
string input = "5";
if (input == "" ||
input == "1" ||
input == "2" ||
input == "3" ||
input == "4" ||
input == "_" ||
input == "6" ||
input == "7" ||
input == "8")
{/* ... */}
else
{/* ... */}
How can I make it look better? Is there some way to remove repeating inputs?
upd: switch will probably make it even worse, because in my case I’m going to check for many conditions, most of which will run very limited number of methods.
Yes, you can write an extension method like this one:
And use it as follows: