Friday, February 20, 2015

Debug & Release Mode code in Visual Studio

Debug & Release Mode code in Visual Studio


Its small but useful feature I come a cross, to execute different code blocks in different modes, I mean 1 in Debug the other in Release.

It’s very useful when I want to execute some logic in local machine (in debug mode) which should not be executed in production or if you want some different code to be executed in production but not in local machine.

Follow the way below to achieve it.

#if DEBUG
   //Debug Code
   //Debug Code
   //Debug Code
   //Your code to execute in debug must be here
#else
    //Release Code
    //Release Code
    //Release Code
    //Your code to execute in release must be here
#endif


that’s it to complete J

No comments: