C# – Will #if RELEASE work like #if DEBUG does in C#

cdebuggingnet

In all the examples I've seen of the #if compiler directive, they use "DEBUG". Can I use "RELEASE" in the same way to exclude code that I don't want to run when compiled in debug mode? The code I want to surround with this block sends out a bunch of emails, and I don't want to accidentally send those out when testing.

Best Answer

RELEASE is not defined, but you can use

#if (!DEBUG)
  ...
#endif