C#'s switch statement can compile to a CIL switch instruction, or if/else's, depending on the cases in the statement as mentioned here. Is there a way to force the compiler to always generate the if/else variant in a block of code?
The simplest way would be to use if/else in your code. Apart from anything else, that makes it clearer to the reader that that's what you want to happen instead of using a switch.
EDIT: Okay, so the readability isn't important for you - but basically if you want the compiled code to change, the source code is going to have to change. You could use the Mono compiler and modify it yourself, but I doubt that there's any way of getting the Microsoft compiler to effectively ignore that you're using a switch statement.
Have you tried a different compiler (i.e., Mono), or tried to place your offending classes in a separate assembly and switch to a different language for it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With