在C#中,如果预处理程序指令是在实际编译之前进行预处理的指令,那么为什么不在该程序中首先执行该指令?
static void Main(string[] args)
{
Program1.display();
Program2 p2 = new Program2();
p2.show();
#if DEBUG
Console.WriteLine("DEBUG from preprocessor directive is working!");
#endif
}
Run Code Online (Sandbox Code Playgroud)
预期产量:
DEBUG from preprocessor directive is working!
.......(from display())
.......(from show())
Run Code Online (Sandbox Code Playgroud)
但是实际输出:
.......(from display())
.......(from show())
DEBUG from preprocessor directive is working!
Run Code Online (Sandbox Code Playgroud)