调试 - 如何逐行执行代码?

发布于 2024-12-06 04:17:46 字数 185 浏览 0 评论 0原文

我很难在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凉城已无爱 2024-12-13 04:17:46

我不完全清楚你想要什么...

  • 如果你不确定如何逐行单步执行,请在你想要开始的地方放置一个断点< /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.

转身泪倾城 2024-12-13 04:17:46

不要单击“运行”按钮,而是单击“单步执行”按钮来启动项目。您不需要任何断点(尽管它们很有帮助),并且可以开始逐行运行代码。只需继续单击“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).

行雁书 2024-12-13 04:17:46

我认为您想使用“单步执行”(F11) 和“单步执行”(F10),这将一次单步执行一行代码(在遇到断点后)

或者使用工具栏,这通常是我尽力而为的做法永远不记得 F 命令,它有工具提示:

调试工具栏图像

来自 此处:

您可以通过多种不同的方法逐步执行代码,您
可以使用 F11 逐行浏览,使用 F10 逐步跳过或单步
使用 (Shift+F11) 输出。

单步执行:将调试所执行的每一行代码。
当调用方法时,流程进入该方法并返回
完成后转到调用线路。

单步执行:如上所述,但是您不会调试内部方法调用。
如果您已经知道某个方法是
工作,只是不调试就调用它。

Step Out:如果您使用 Step Through 输入方法,Step Out 将
返回到调用该方法的位置。

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:

image of debugging toolbar

From here:

You can step through the code in a number of different methods, you
can step through line by line using F11, step over using F10 or step
out using (Shift+F11).

Step Through: Each and every line of code executed will be debugged.
When a method call is invoked the flow enters the method and returns
to the calling line after it has completed.

Step Over: As above, however you will not debug internal method calls.
This is a better debug tool if you already know that a method is
working and just wasn’t to call it without debugging.

Step Out: If you entered a method using Step Through, Step Out will
return you to the point that method was called.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文