#492 – Define Your Own Conditional Compilation Symbol
January 6, 2012 Leave a comment
You can define your own conditional compilation symbols for specific build configurations and then use the #if directive to check these symbols and conditionally compile code, depending on whether the symbol is defined or not.
For example, suppose you want to execute some debugging code only for Debug builds that are targeting the x86 platform. You can define a new DEBUG86 symbol that is present only when the build configuration is Debug and the platform is x86.
You can then use the #if directive to compile some code only when this symbol is defined.
#if DEBUG86 Console.WriteLine("This is a 32-bit Debug build.."); #endif