We help IT Professionals succeed at work.
Get Started

Question about "#if DEBUG"

lapucca asked
Last Modified: 2015-09-24
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?
     output this message;
    output this other message;
Watch Question
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE