#undef, #elif, and #else preprocessor directives : Macro « Development Class « C# / C Sharp






#undef, #elif, and #else preprocessor directives

#undef, #elif, and #else preprocessor directives

#define DEBUG
#undef DEBUG
#define PRODUCTION
   
class Test {
  public static void Main() {
    int total = 0;
    int counter = 10;
   
    myLabel:
    System.Console.WriteLine("counter = " + counter);
    if (counter < 5) {
#if DEBUG
      System.Console.WriteLine("goto myLabel");
#elif PRODUCTION
      System.Console.WriteLine("counter < 5");
#else
      System.Console.WriteLine("goto myLabel, counter < 5");
#endif
      goto myLabel;
    }
    System.Console.WriteLine("total = " + total);
  }
}

           
       








Related examples in the same category

1.The use of the #define, #if, and #endif preprocessor directivesThe use of the #define, #if, and #endif preprocessor directives
2.Define macro for conditional compile
3.Macro in action