我使用 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/