Use marco to define flag variable : Preprocessor Directives « Language Basics « C# / C Sharp






Use marco to define flag variable

 


#define DEBUGGING

using System;

class Starter {
#if DEBUGGING
    static void OutputLocals() {
        Console.WriteLine("debugging...");
    }
#endif
    static void Main() {
#if DEBUGGING
        OutputLocals();
#endif
    }
}

 








Related examples in the same category

1.line number
2.precompile marco: define, undef, elif, endif
3.#undef Marco
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