I partially relate to switch statements in an array of arguments and setting properties in some configuration class for each expected argument. It looks like you are expecting a string of strictly formatted argument, and not allowing the given values, you can try:
if(args[0].Trim() == PROCESS_OPTION_ONE || args[0].Trim() == PROCESS_OPTION_TWO) { //Process file - Argument 2 switch(args[1].Trim() { case PROCESS_CUSTOMER, PROCESS_ADMIN, PROCESS_MEMBER, PROCESS_GUEST, PROCESS_USER: // Do stuff break; default: // Do other stuff break; } }
My preferred method will look like
foreach(string arg in args) { switch(arg) { case PROCESS_CUSTOMER:
NOTE: args.Length == 1 is faster than args.Length> 0 && args.Length <2. It is also a bit readable.
source share