I'm building a console application to help expidite some stuff I do regularly. I have a menu with 4 options of procedures, which translate to different methods in my class.
Basicaly it's kind of like this:
What do you want to do?
1 This Thing
2 That Thing
3 Some Stuff
4 Cool Stuff
0 All The Stuff.
Input command string:_
Currently I'm checking for valid input with:
while (command.IndexOfAny("12340".ToCharArray()) == -1)
{
//Display the menu and accept input
}
And then controlling flow with:
if (command.IndexOf("1") > 0 )
{
thisThing();
}
if (command.IndexOf("2") > 0 )
{
thatThing();
}
if (command.IndexOf("3") > 0 )
{
someStuff();
}
if (command.IndexOf("4") > 0 )
{
coolStuff();
}
if (command.IndexOf("0") > 0 )
{
thisThing();
thatThing();
someStuff();
coolStuff();
}
The goal is to provide input and run one or more processes as indicated:
1 : thisThing()
13 : thisThing() and someStuff();
42 : thatThing() and coolStuff();
0 : run all processes I have defined.
Is there a way to do something like this with better practices?