1
9
您可以使用条件代码部分:
或者,您可以使用
如:
|
2
4
这是一个很好的参考资料。 http://www.csharphelp.com/archives/archive36.html 从源头上看,这是一个很好的例子:
|
3
1
两种主要的解决方案是预处理器指令和 Conditional attribute . 相关的预处理器指令的工作方式如下:
条件属性应用于方法:
然后所有 电话 只有在定义了调试时才会编译到dodebugonly()。 这两种方法也适用于任何其他预处理器标识符。trace是集成到Visual Studio中的另一个示例,但您定义的任何预处理器标识符都有效:
|
4
0
根据您要做的工作,您可能需要考虑日志框架,例如 log4net 或者 Logging Application Block .这些将允许您在代码中保留调试消息,但仅当外部配置文件要求时才输出这些消息。 但是,如果您想添加/删除实际执行逻辑的代码,请使用其他答案。 |
SRobertJames · 使用printf的gdb显示 1 年前 |
Subin · 在vscode中运行c时出错 1 年前 |
Community wiki · 如何调试Python内存故障? 1 年前 |
Kai · 有什么方法可以轻松优化VSCode中的锈迹? 2 年前 |
Chris Brandon · 如何使节点在堆栈溢出时中断? 2 年前 |