Visual Studio C#调试没有断点的特定变量

时间:2017-05-30 08:16:56

标签: visual-studio-2015

在一个项目中,我不想使用断点来查看变量值,所以我使用:

Debug.WriteLine("This is a test.", "SomeIdentifier");

Debug来自“System.Diagnostics”,“这是一个测试”。被替换为一些变量值。现在,当我查看调试输出窗口时,我看到一个非常大的列表,我可以通过在此窗口中显示ProgramOutput(右键单击输出窗口 - >程序输出)使列表更小。但是仍然有一个很大的列表,而我只想查看具有特定标识符的相同变量的值,如“SomeIdentifier”。我可以使用ctrl + f来搜索项目,而不是寻找它们并节省一些时间,但它仍然没有效果。例如以下情况:

我在我的asp.net应用程序上运行大量调用以进行压力测试,并希望查看特定变量是否有效,并且只查看该特定变量。我只想查看该值的列表,例如。

SomeIdentifier - 1
SomeIdentifier - 2
SomeIdentifier - 3
SomeIdentifier - 4

而不是:

SomeIdentifier - 1
some other stuff    some other stuff    some other stuff
some other stuff    some other stuff
some other stuff           some other stuff 
SomeIdentifier - 2
some other stuff    some other stuff    some other stuff
SomeIdentifier - 3
some other stuff    some other stuff
some other stuff    some other stuff    some other stuff
some other stuff    some other stuff
some other stuff
some other stuff
SomeIdentifier - 4

我可以写入日志文件,但声音效率不高(需要在日志框架中添加更多代码/依赖项来记录变量)。是否可以在不使用断点或必须搜索列表/创建日志文件的情况下调试特定变量?

注意:我正在使用C#

1 个答案:

答案 0 :(得分:-1)

我刚刚测试了this post中建议的内容:

  

右键单击Debug选项的Output窗口;在这里,您可以选择要查看的消息类型。

取消选中除节目输出以外的所有内容

这对我有用,这是我在VS 2013下的测试:

enter image description here