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

Brian Sullivan picture Brian Sullivan · Feb 3, 2009 · Viewed 125.7k times · Source

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.

Answer

M4N picture M4N · Feb 3, 2009

RELEASE is not defined, but you can use

#if (!DEBUG)
  ...
#endif