|
1 | 1 | --- |
2 | 2 | title: "Tutorial: Debug C# code and inspect data" |
3 | 3 | description: Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application. |
4 | | -ms.date: 10/25/2023 |
| 4 | +ms.date: 10/24/2024 |
5 | 5 | ms.subservice: debug-diagnostics |
6 | 6 | ms.topic: tutorial |
7 | 7 | dev_langs: |
@@ -510,58 +510,6 @@ For more about the **Call Stack**, see [How to: Examine the Call Stack](../../de |
510 | 510 |
|
511 | 511 | ::: moniker-end |
512 | 512 |
|
513 | | -## Change the execution flow |
514 | | - |
515 | | -::: moniker range="<=vs-2019" |
516 | | - |
517 | | -1. Press **F11** twice to run the `Console.WriteLine` method. |
518 | | - |
519 | | -1. With the debugger paused in the `SendMessage` method call, use the mouse to grab the yellow arrow or execution pointer (in the left margin), and drag the pointer up one line to the `Console.WriteLine` statement. |
520 | | - |
521 | | -1. Press **F11**. |
522 | | - |
523 | | - The debugger reruns the `Console.WriteLine` method (you see this action in the console window output). |
524 | | - |
525 | | - By changing the execution flow, you can do things like test different code execution paths or rerun code without restarting the debugger. |
526 | | - |
527 | | - > [!WARNING] |
528 | | - > Often you need to be careful with this feature, and you see a warning in the tooltip. You may see other warnings, too. Moving the pointer cannot revert your application to an earlier app state. |
529 | | -
|
530 | | -1. Press **F5** to continue running the app. |
531 | | - |
532 | | - Congratulations on completing this tutorial! |
533 | | - |
534 | | -::: moniker-end |
535 | | - |
536 | | -::: moniker range=">=vs-2022" |
537 | | - |
538 | | -You can move the execution pointer to change the flow of your app while debugging. |
539 | | - |
540 | | -1. With the debugger paused at the `SendMessage` method call in the `for` loop, select **F11** three times to step into the `SendMessage` method and to move past the `Console.WriteLine` method after executing it. |
541 | | - |
542 | | - The debugger is now paused at the final closing brace of the `SendMessage` method. |
543 | | - |
544 | | -1. Use the mouse to grab the yellow arrow or execution pointer (in the left margin), and then drag the pointer up one line. |
545 | | - |
546 | | - The debugger is now back on the `Console.WriteLine` statement. |
547 | | - |
548 | | -1. Select **F11**. |
549 | | - |
550 | | - The debugger reruns the `Console.WriteLine` method, and you see a duplicate line in the console window output. |
551 | | - |
552 | | -1. Select **F5** to continue running the app. |
553 | | - |
554 | | -By changing the execution flow, you can do things like test different code execution paths or rerun code without restarting the debugger. |
555 | | - |
556 | | -> [!WARNING] |
557 | | -> Use this feature with care. You'll see a warning in the tooltip of the execution pointer about the possibility of unintended consequences. You might see other warnings, too. Moving the execution pointer can't revert your application to an earlier state. |
558 | | -
|
559 | | -For more about the changing the execution flow, see [Move the pointer to change the execution flow](/visualstudio/debugger/navigating-through-code-with-the-debugger?view=vs-2022#BKMK_Set_the_next_statement_to_execute&preserve-view=true). |
560 | | - |
561 | | -Congratulations on completing this tutorial! |
562 | | - |
563 | | -::: moniker-end |
564 | | - |
565 | 513 | ## Next steps |
566 | 514 |
|
567 | 515 | In this tutorial, you've learned how to start the debugger, step through code, and inspect variables. You might want to get a high-level look at debugger features along with links to more information. |
|
0 commit comments