I have a code that should run only in debug mode.
Is it better to use HttpContext.Current.IsDebuggingEnabled or “#if DEBUG … #endif”?
Thanks,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the debug code should absolutely not be compiled into your release assemblies, then it’s better to use
#ifstyle (or consider using conditional methods).When using
#if DEBUGblocks (or conditional methods), the code will not be compiled into your assembly if the build is not aDebugbuild i.e. theDEBUGcompilation symbol is not defined.