调试 - 如何逐行执行代码?
我很难在 Visual Studio 中调试我的 C# 应用程序。我不知道如何逐行调试代码,但在程序启动时不知道(因为我必须按 F5 多次,因为程序仅需要大约 200 行来初始化)。我的意思是,假设我希望在某个时刻开始调试。就像在每一行代码中都有一个断点,但没有实际创建断点(每次我想要创建断点时都会花费很多时间)。
我希望我说得比较清楚。
I am having a hard time debugging my C# app in Visual Studio. I can't figure out how to debug code line by line, but not at the moment the program starts (because I would have to F5 a lot of times as the program takes about 200 lines just to initialize). I mean let's assume I would like the debugging to start in a certain moment. Something like having a breakpoint in every line of code but without actually creating the breakpoints (which would take a lot of time every time I want them to be created).
I hope I am somewhat clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不完全清楚你想要什么...
如果你不确定如何逐行单步执行,请在你想要开始的地方放置一个断点< /em> 逐行调试(或暂停应用程序),然后使用 F10 作为“Step Over”或 F11 作为“Step Into”,而不是 F5知识库> (“Go”)。
如果您不确定如何在需要时闯入应用程序,您可以随时点击调试器中的“暂停”按钮,或者在应用程序启动后您想要停止的位置添加断点.
如果这些都没有帮助,请提供更多信息。
I'm not entirely clear what you're after...
If you're not sure how to step line, by line, put a breakpoint where you want to start debugging line by line (or pause the app) then use F10 as "Step Over" or F11 as "Step Into" instead of F5 ("Go").
If you're not sure how to break into the app when you want to, you can hit the "pause" button in the debugger at any time, or add a breakpoint where you want to stop even after the app has started.
If neither of these is helpful, please give more information.
不要单击“运行”按钮,而是单击“单步执行”按钮来启动项目。您不需要任何断点(尽管它们很有帮助),并且可以开始逐行运行代码。只需继续单击“Step Over”(如果您想单步执行方法的实现,则单击“Step Into”)。
Instead of clicking the Run button, click the Step Over button to start your project. You won't need any breakpoints (although they are helpful) and you can start running your code line by line. Just keep clicking Step Over (or Step Into if you want to step into a method's implementation).
我认为您想使用“单步执行”(F11) 和“单步执行”(F10),这将一次单步执行一行代码(在遇到断点后)
或者使用工具栏,这通常是我尽力而为的做法永远不记得 F 命令,它有工具提示:
来自 此处:
I think you want to use Step Into (F11) and Step Over (F10) which will step through your code one line at a time (after you have hit a breakpoint)
Or use the toolbar, which is generally waht I do as I can't ever remember the F commands, and it has tooltips:
From here: