Share article .NET Interview question: - What is the use of DEBUG directive?: #Debug is a preprocessor directive. Now many times you want some code to run whil ...
#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.
#if DEBUG
// This code will not be shipped to production.
Console.WriteLine(System.Environment.OSVersion);
#endif
// This code will be shipped to production.
for (int i = 0; i < 5 ; i++)
{
Console.WriteLine(i);
}
This question is taken from the book .NET Interview question and answers by Shivprasad Koirala.
Watch the below video, c# and .NET Interview questions: - What is the use of DEBUG directive?
See for more stuffs on Most asked Dotnet interview questions
Regards,
Click to view more from author's on Dotnet interview questions and answers
.Net interview questions: - Explain why it is not preferred to use finalize for clean up?
.Net interview questions: - Show the five levels in CMMI?
C# interview questions and answers: – Explain the use of Icomparable in c#?
C# interview questions: - How can we check which rows have changed since dataset was loaded?
C# interview questions and answers: - Can you write a simple c# code to display Fibonacci series?
.NET interview questions and answers: - What is difference betweenIcomparable VS Icomparer ?
C# and .NET interview question: -What is short circuiting in C#?
C# and .NET interview question: - What are symmetric and asymmetric algorithms?
Important c# and .NET interview question on object pooling and Gridview events?
.NETinterview questions and answers: – Will
the finally run in this code?
How to prepare for c# and .NETinterviews?
C# and .NET Interview questions: - What is Thread.Join () in threading?
.NET Interview questions and answers: -What is serialization and deserialization in .NET?
C# and .NET interview question: - What is hashing?
c# and .NET interview question:- what connects dataset and data source ?
.NET interview questions and answers: - What is TPL?
.NET Interview questions and answers: -What are different access modifiers?
MVC ( Model view controller) interview questions and answers
ASP.NET Application and Page Life Cycle
6 important use of Partial/Mock testing
6 important uses of Delegates and Events
7 Simple Steps to Run Your First Azure Blob Program
8 Steps to Create Workflows using SharePoint Designer
C# Code Reviews using StyleCop – Detailed Article
Four real world uses of Partial classes and Partial methods
SharePoint Quick Start FAQ Part 1
SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows
MVC Interview questions and answers Article
(Model view controller)MVC Interview questions and answers
MVC interview questions with answers video: – What is Web API how to implement the same?
WCF Interview questions videos
C# Interview Questions & Answers Article
6 important use of Partial/Mock testing
6 important uses of Delegates and Events
7 Simple Steps to Run Your First Azure Blob Program
8 Steps to Create Workflows using SharePoint Designer
C# Code Reviews using StyleCop – Detailed Article
Four real world uses of Partial classes and Partial methods
SharePoint Quick Start FAQ Part 1
SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows
C# (Csharp) interview questions and answers: – What are indexers in .NET?
C# OOP interview questions and answers: - I do not want to implement all the interface methods?
C# design pattern (UNIT of Work Design Pattern)
C# design pattern interview questions – What
is Dependency injection ?
C# interview questions and answers: - What is the difference between
“==” and .Equals()?
How questions are asked in c# interviews?
C# design pattern interview question: - DI vs IOC
8 important C# Interview questions on IL code, JIT, CLR, CTS, CLS and CAS
What is the difference between Reflection and Dynamic in C#?
Algorithm interview questions and answers: – Can you write code for bubble sort algorithm?
Algorithm interview questions and answers: – What is inserted sort algorithm?
SQL Server Interview Questions & Answers Article
SQL Server interview questions and answers: - What is HID data type in SQL Server ?
.NET INTERVIEW QUESTIONS & ANSWERS ARTICLE
.NET interview questions and answers: - How to reverse a string in .NET ( DotNet)?
.NET interview questions and answers: - What is the use of Click Once?
.NET interview questions and answers: - Will the below codes create new instances?
C# and .NET interview questions with answers – What is Nuget?
Dependency injection (DI) VS Inversion of Control (IOC)
.NET interview questions with answers: - What is the difference between Reflection and Dynamic?
WPF INTERVIEW QUESTIONS & ANSWERS ARTICLE
6 important WPF and Silverlight Multi-threading interview questions with answers