如何在 Visual Studio 调试器中的某个点中断循环?
我有一个 for 循环,它在字符串数组上运行 1000 多次。
我想让我的应用程序在其中一个字符串与某个术语匹配时中断。
所以我可以从那时开始浏览我的代码。
现在,我知道我可以添加一段代码来查找它并在它命中时添加一个断点,但是没有办法在调试器中执行此操作吗?
I have a for
-loop which runs for 1000+ times over a string array.
I want to have my app break when one of the strings matches a certain term.
So I can walk through my code from that point.
Now, I know I can add a piece of code that looks for this and a breakpoint when it hits, but is there not a way to do this in the debugger?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
转到您的代码,
,或者
在循环中间
写入
并中断整数a=1;
第二种方法看起来更像是垃圾,但我发现它更容易、更快
Go to your code
or
at the middle of your loop
write
and break over int a = 1;
The second method looks more like garbage, but I find it easier and faster to do
是的,您可以在调试器中。 这称为“条件断点”。 基本上,右键单击红色断点并转到“条件”选项。
谷歌快速浏览了此和this up:
PS 最后一张是VS 2005,不过2008年也是这样。
Yes, you can in the debugger. It's called a "conditional breakpoint." Basically, right click on the red breakpoint and go to the "condition" option.
A quick google turned this and this up:
P.S. The last one is VS 2005, but it's the same in 2008.
在 Visual Studio 中,您可以设置条件断点:
选择“条件断点...”。
true
的表达式,(例如 i == 1000,或 MyString =“hello world”)
In Visual Studio you can set a conditional breakpoint:
select "Conditional Breakpoint...".
true
when you want to break,(e.g. i == 1000, or MyString = "hello world")