问题描述
我正在尝试向输出窗口写一个消息进行调试。我搜索了一个函数,如Java的 system.out.println()
。我试过 Debug.Write
, Console.Write
和 Trace.Write
。它不会发出错误,但它也不会打印任何东西。
I am trying to write a message to the output window for debugging purposes. I searched for a function like Java's system.out.println("")
. I tried Debug.Write
, Console.Write
, and Trace.Write
. It does not give an error, but it does not print anything either.
定义DEBUG常量和定义TRACE常量选项。
"Define DEBUG constant" and "Define TRACE constant" options are checked.
菜单工具→选项→调试→将所有输出窗口文本重定向到立即
Menu Tools → Options → Debugging → "Redirect all Output Window text to the Immediate Window" option is not checked.
配置:Active(Debug)
Configuration: Active (Debug)
注意:我使用向导创建一个项目为Windows窗体应用程序,如果相关。我不知道在哪里看。
Note: I created a project with the wizard as "Windows Forms Application" if relevant. I have no idea where to look.
推荐答案
添加 System.Diagnostics
命名空间,然后您可以使用 Debug.WriteLine()
快速打印到IDE输出窗口的消息。有关详细信息,请参阅这些:
Add the System.Diagnostics
namespace, and then you can use Debug.WriteLine()
to quickly print a message to the output window of the IDE. For more details, please refer to these:
- How to trace and debug in Visual C#
- A Treatise on Using Debug and Trace classes, including Exception Handling
这篇关于写入Visual Studio的输出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!