简体   繁体   English

Visual Studios 中的 C#:如何在断点期间打印到控制台

[英]C# in Visual Studios: How to print to console during a break point

I do not normally code in C# and was wondering if Visual Studio had a particular debugging feature that is similar to the Python Debugger.我通常不会在 C# 中编码,我想知道 Visual Studio 是否具有类似于 Python 调试器的特定调试功能。 In the PDB, during a breakpoint I will often print certain function calls and variables as well as test certain if statements.在 PDB 中,在断点期间,我经常会打印某些 function 调用和变量,并测试某些 if 语句。 Although I can see variables in the 'locals' tab, I can't do print statements like list[i] or foo(var) or if(f(x) == 1) which I think are powerful debugging tools.虽然我可以在“locals”选项卡中看到变量,但我不能执行我认为是强大的调试工具的 list[i] 或 foo(var) 或 if(f(x) == 1) 之类的打印语句。 Is this feature at all available in VS?这个功能在VS中完全可用吗? Thanks for the help.谢谢您的帮助。

In Visual Studio, you can "Insert Tracepoint" from the context menu under "Breakpoint".在 Visual Studio 中,您可以从“断点”下的上下文菜单中“插入跟踪点”。 Alternatively, you can create a breakpoint and open its properties then set the "Actions" checkbox.或者,您可以创建一个断点并打开其属性,然后设置“操作”复选框。

插入跟踪点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM