I have this code in my C# class.
#if DEBUG
private const string BASE_URL = "http://www.a.com/";
#else
private const string BASE_URL = "http://www.b.com//";
#endif
What I wanted to ask is when does the
#if DEBUG
path in the code get executed?
Does it get executed
- When I run up a debug session in Visual Studio?
- When I manually run the exe or dll in question from the debug folder?
- Any other circumstances I forgot to mention?
#if DEBUGIt’s a preprocessor definition.It compiles when you define DEBUG constant. And yes, it’s default on Debug Build Configuration.
Visual Studio 2010 Project Properties:

If
Define DEBUG constantis checked VS will compile:Else (not checked) VS will compile: