c# - 我们在哪里使用 Debug/Trace 语句

标签 c#

我使用 C#(使用 VS IDE)进行开发。我对调试/跟踪语句感到困惑。

我们在哪里以及为什么使用这些语句?

我经常在其他开发人员的源代码中看到这些。

谁能指点一下?

最佳答案

Debug 语句仅出现在 Debug 版本中。

Trace 语句存在于调试和发布版本中。

为了调试或检查,您可以将 Debug 和 Trace 语句放在要输出某些值的地方。

这篇 MS 支持文章可能会引起您的兴趣:How to trace and debug in Visual C#

The Trace class routes messages to listeners: classes that are designed to accept Trace messages and send them to an appropriate output device. The Trace.Listeners collection contains a list of the listeners that are registered with the system. Calling any of the Trace output methods will send a message to all of the registered listeners. A class called DebugTraceListener is automatically added to the Listeners collection, and routes messages to the OutputDebugString Win32 API function.

SysInternals DebugView应用程序将捕获通过 OutputDebugString 定向的任何输出。

关于c# - 我们在哪里使用 Debug/Trace 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1218211/

相关文章:

c# - 从 C# 调用 Delphi DLL 函数

c# - 我能得到导致异常的代码行吗?

c# - C#-从输入数字中删除空格以具有int

c# - 使用 UIView.Animate 动画图层不透明度

c# - Microsoft Visual Studio C# 安装程序

C# .NET4.5.1 正则表达式奇怪?

c# - 如何将文本框的边框颜色重置为默认系统颜色

c# - 表示数学未知数的可空类成员

c# - PDF文档中JBIG2过滤流的结构是什么

c# - 如何从 Gridview 中获取行并将它们插入数据库?