I am attempting to implement a switch statement to call the correct function upon receiving an external command. I have about 15 commands and I thought a switch statement would be appropriate.
I figured I would get the best performance if I built the switch statement from top to bottom by prioritizing the expected frequency and desired speed of processing for the different messages.
What I found instead is that the IL seems to suggest that it is the actual byte value of the command’s opcode (the variable about which I switch) that dictates the order of processing. I.E. command 0xA1 will be checked against before 0xA2. Assigning new values to the commands would require an update to already released software and is not the solution I want to jump to.
I’m writing in Netmf 4.3 using VS 2013. Is there a way I can command the compiler to order my switch cases in the way I desire without swapping my switch for a less pretty if-else chain?