Debugging - how do I execute code line by line?
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开发者_C百科 somewhat clear.
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.
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).
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:
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.
精彩评论