CSharp examples for Language Basics:Preprocessor
Syntax for conditional directive is
#if symbol [operator symbol]...
Operators could be either of the following:
#define DEBUG//from www . j a va 2s . com #define MyFlag using System; public class TestClass { public static void Main() { #if (DEBUG && !MyFlag) Console.WriteLine("DEBUG is defined"); #elif (!DEBUG && MyFlag) Console.WriteLine("MyFlag is defined"); #elif (DEBUG && MyFlag) Console.WriteLine("DEBUG and MyFlag are defined"); #else Console.WriteLine("DEBUG and MyFlag are not defined"); #endif } }