根据 this 上接受的答案问题:
When the application is compiled in the release configuration,
the Debug elements will not be compiled into the code.
Debug.WriteLine()(和类似函数)的参数表达式求值副作用是否发生在发布版本中?我不确定“调试元素”的真正含义。
最佳答案
这很简单,你自己试试看:
class Program
{
static void Main(string[] args) {
int i = 0;
Debug.WriteLine(i++);
Console.WriteLine(i);
Console.ReadLine();
}
}
在 Debug模式下,控制台打印 1。在 Release模式下,控制台打印 0。
关于c# - Debug.WriteLine() 参数表达式求值副作用是否发生在发布版本中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38017881/