Use “Run to Cursor” in Visual Studio for Saving Time While Debugging
Time is the main constraint for developer. This article explains how you can boost up your productivity of work while debugging in Visual Studio to a specific line of code.
Run to Cursor is a great and a hidden features of Visual Studio. Whenever you need to debug your code to a specific logic, you debug it step by step. You can really avoid this step by step debugging and directly stop the debugger where you are targeting it to stop.
Run to Cursor is just like a breakpoint, but in this case you don’t need to start the Visual Studio debugger manually.
When you select the run to cursor option, visual studio starts the debugger automatically and execution stopped to the selected line.
We have a console application program here. We are taking 2 numbers as input from user and preforming some calculation using Calculate(num1, num2) function.
Now let’s assume that we want to debug line highlighted in image.
So Right Click on that line and select Run to Cursor from context menu. Debugger will start automatically (i.e. Visual Studio will start execution) and after taking input from user, execution will stop to this line.
You can also use “ctrl + f10” shortcut key to call run to cursor command.