Demonstrate #else. : if « Preprocessing Directives « C# / CSharp Tutorial






#define AAA 
#define BBB 
 
using System; 
 
class Test { 
  public static void Main() { 
     
    #if AAA 
      Console.WriteLine("Compiled for AAA version."); 
    #else 
      Console.WriteLine("Compiled for release."); 
    #endif 
 
    #if AAA && BBB 
       Console.Error.WriteLine("Testing AAA and BBB version."); 
    #else 
       Console.Error.WriteLine("Not (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.3.if
16.3.1.Demonstrate #if, #endif, and #define.
16.3.2.Demonstrate #else.