Conditional Compilation

Sakthi.Singaravel
Posted by Sakthi.Singaravel under C# category on | Points: 40 | Views : 1007
Conditional Compilation using C#

Let's we look C# #IF statement..

class Program
{
static void Main(string[] args)
{
#if DEBUG
Console.WriteLine("My debug entries");
#endif
Console.WriteLine("Program Ends");
Console.ReadKey();
}
}


When C# compilers compiles the above code, compiler looks #IF directive's condition...

Console.WriteLine("My debug entries"); 


The above line is present in inside of the #IF directive with DEUG condition...

If we build the project in "Debug" mode, that line executes, otherwise not..

Comments or Responses

Login to post response