Pre-processor directives

Visual Studio automatically generates a pre-processor directive called DEBUG which is linked to the mode you run your application in.
All these directives are case sensitive!
Pre-processor directives can be defined using #define (making the directive true) and #undef (making it false) in C#. You can check for any defined directive using the #if ... #else ... #endif statement.

Visual Studio IDE is even able to even grey out the code that will not be compiled regarding the current selected directive: DEBUG or RELEASE. This way you are aware, by a simple look, of which code is about to be used when the application is started.

Debug mode

If the DEBUG mode is currently selected, this is how our test code will look like. Please note the grey line!

C# .NET

string value = String.Empty;

#if (DEBUG)

value = "DEBUG value";

#else

value = "RELEASE value"; // This will not be executed!

#endif

Release mode

If the RELEASE mode is currently selected, this is how our test code will look like. Please note the grey line which is different now from the one on DEBUG mode!