Search code examples
c#compiler-directives

C# Compiler Directives


I’m looking at some C# code, and have come across the following statement:

#if DEBUG
    // Do something here
#else
    // Do something else
#endif

I assumed that DEBUG would be a defined somewhere as follows:

#define DEBUG

But I’m unable to find such a definition, although the code seems to behave as though it were set. Is DEBUG a special case, and if so, how is it set / unset?


Solution

  • On the project, go to Properties -> Build. Under general, you have an option there for defining both DEBUG and TRACE.