Sunday, April 28, 2013

.NET code to execute only when in debug configuration

Leave a Comment

.NET code to execute only when in debug configuration

#if DEBUG
// do debug only stuff
#else
// do non DEBUG stuff
#endif

Visual Studio automatically defines DEBUG when you are in the debug configuration. You can define any symbols you want (look at your project's properties, the build tab). Beware that abusing preprocessor directives is a bad idea, it can lead to code that is very difficult to read/maintain.
Read More...