How can I disable compiler optimization in C#?

At the command line (csc), /optimize-

In the IDE, project properties → build → "optimize code"

For some JIT optimizations, you can use [MethodImpl(...)]


Set Configurations to All Configurations

Set Optimized code checkbox to unchecked

enter image description here