#undef Marco : Preprocessor Directives « Language Basics « C# / C Sharp






#undef Marco

 


#define MYOWN
#define DEBUG
#undef VERBOSE
#define PROGRAMMER_IS_BRIAN
#undef PROGRAMMER_IS_DAVE

using System;

class Preprocessor {
    static void Main() {
#if MYOWN
        Console.WriteLine("Hi Author!");
#elif VERBOSE
   Console.WriteLine("Program Starting?);
#endif
        int a = 10, b = 5;
#if DEBUG
        Console.WriteLine("a={0}, b={1}", a, b);
#endif

#if MYOWN && (VERBOSE || DEBUG)
        Console.WriteLine("Continuing, Author");
#elif !MYOWN && (VERBOSE || DEBUG)
   Console.WriteLine("Continuing?);
#endif

#if PROGRAMMER_IS_BRIAN || PROGRAMMER_IS_DAVE
#warning Execution may vary depending on programmer.
#endif

#if PROGRAMMER_IS_DAVE
#error Something you did broke this code.
#endif
    }
}

 








Related examples in the same category

1.line number
2.precompile marco: define, undef, elif, endif
3.Use marco to define flag variable
4.Demonstrates the use of a conditional methodDemonstrates the use of a conditional method
5.#define, #if, and #endif preprocessor directives#define, #if, and #endif preprocessor directives
6.#undef, #elif, and #else preprocessor directives#undef, #elif, and #else preprocessor directives
7.Demonstrate #if, #endif, and #defineDemonstrate #if, #endif, and #define
8.Use a symbol expressionUse a symbol expression
9.Demonstrate #elseDemonstrate #else
10.Demonstrate #elifDemonstrate #elif
11.Preprocessor 2Preprocessor 2