Avatar of lapucca
lapucca
 asked on

Question about "#if DEBUG"

Hi, I'm using VS2013, C# and asp.net web form
I want to print out messages from application to be different when it's in Debug mode and when it's in Release mode.  I'm confused about how to use the #if DEBUG  statement.  Do I need to have "#define DEBUG " statement at the top of the main page aspx?  Reading this link just confuses me, https://msdn.microsoft.com/en-us/library/4y6tbswk.aspx    and   http://stackoverflow.com/questions/1734741/how-to-execute-code-only-in-debug-mode-in-asp-net 

I want the program to auto detect if it's in DEBUG mode but if I use the define statement does that always put it in DEBUG mode?
Thank you.

Does syntax like this is correct?
#if DEBUG
     output this message;
#else
    output this other message;
C#.NET Programming

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mlanda T

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Mlanda T

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
lapucca

ASKER
Thank you.
Fernando Soto

To your question :

Does syntax like this is correct?
#if DEBUG
     output this message;
#else
    output this other message;

If before this code you have #define DEBUG then "output this message;" will be executed if it is not appear before the statement then " output this other message;" this will be executed.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23