1. Back To Blog

.NET interview questions: - What is the use of DEBUG directive?

#Debug is a preprocessor directive. Now many times you want some code to run while you are debugging but you do want those code shipped to production environment.


For instance in the below code we want to display operating system only during debugging but this code we do not want in to be pushed to production server.To achieve this we can use the DEBUG directive.


You can see the below code we have wrapped display operating version code in #if DEBUG condition. This code will be excluded when release compiling happens.



Also see following .NET interview questions video on Debug directive in C#: -


Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social