Use a symbol expression. : define « Preprocessing Directives « C# / CSharp Tutorial






#define AAA 
#define BBB 
 
using System; 
 
class MainClass { 
  public static void Main() { 
     
    #if AAA 
      Console.WriteLine("Compiled for AAA version."); 
    #endif 
 
    #if AAA && BBB 
       Console.Error.WriteLine("Testing AAA and BBB version."); 
    #endif 
   
    Console.WriteLine("This is in all versions."); 
  } 
}
Compiled for AAA version.
Testing AAA and BBB version.
This is in all versions.








16.1.define
16.1.1.A list of preprocessor commands available in C#:
16.1.2.Preprocessing Directives: define
16.1.3.Use a symbol expression.
16.1.4.Use the Conditional attribute with define