Is there a way in C# to replicate a '#ifndef _DEBUG' from C/C++?

c#, debugging, programming-languages

Solution

#if DEBUG
    Console.WriteLine("Debug version");
#endif

#if !DEBUG
    Console.WriteLine("NOT Debug version");
#endif

See this.

Problem

I'd like to conditionally exclude/include code based on whether I'm building in debug mode. Can I use something as simple as a `#ifndef _DEBUG` as I would in C++?

Original source