If you are new to Visual Studio or in beginning stage of developer, here some tips which will help you to work in Visual studio quickly and more effectively. There are some basic things like debugging, break point, files navigation, DataTips, Watch window and other commonly used tools which you should know before starting to use Visual Studio.
To debug your application, press F5, or select Debug > Start Debugging, or select the green arrow in the Visual Studio toolbar.
Note: To run your application without debugging, press CTRL + F5, or select Debug > Start Without Debugging. This will run your application by skipping all enabled breakpoints.
You can put the break point where you want to start the inspection of your code. This can be any line or statement of code. You may prefer to run directly to a specific location or function when you know exactly what code you want to debug, or you know where you want to start debugging. While you’re debugging, a yellow highlight shows on the code line that will execute next.
To set a simple breakpoint in your code, click the far-left margin next to the line of code where you want to inspect.
You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert Breakpoint.
Refer the below screenshot, yellow highlights shows on break point line.
Inspect inside the code
To step into code or statement line by line while debugging, use Debug > Step Into, or press F11. The debugger steps through each code statements, not physical lines.
To step through code and skip some functions which you may not care about that function while debugging, or you know it works, like well-tested library code. You can use Debug > Step Over or press F10 to skip through code. The functions still execute, but the debugger skips over them.
DataTip shows only in break pointed variables which are in the current scope of execution. When you are at the breakpoint, you can see the DataTip by hover over any variable in the current scope. A DataTip appears by showing the name and current value of the variable. Refer below screenshot,
You can pin a DataTip so that it stays open, select the pushpin Pin to source icon.
To unpin or close the pinned DataTip, refer below screenshot.
If you want to continue to watch a variable while debugging, you can add it to a Watch window from DataTip. Right-click the variable in the DataTip and select Add Watch. The variable appears in the Watch window. You can add a greater number of variables to Watch window. Refer below screenshot.
You can use the Immediate window to debug and evaluate expressions, execute statements, and print variable values. The Immediate window evaluates expressions by building and using the currently selected project. To display the Immediate window, choose Debug -> Windows -> Immediate or press CTRL + ALT + I. The Immediate window is useful when you are debugging an application. The Immediate window supports IntelliSense.
To display the value of a variable
num, you can use the below command
To display the value of evaluated expression
, you can use the commands
? num +
num1 – 50
? num = DateTime.Now.Day + num1
You can cut, copy, paste, and clear all commands in the immediate window by right click on the immediate window.
When you type a code in the editor window, we will see the IntelliSense information. We say the results such as List Members, Parameter Info, Quick Info, Signature Help, and Complete Word are IntelliSense information. This IntelliSense search result uses fuzzy matching of text algorithm. For example, the results list for List Members includes not only entries that start with the characters that you have entered but also entries that contain the character combination anywhere in their names.
Refer the below screenshot,
Quick Navigation or Go To
To open go to window, use CTRL + T or Edit > Go To. Go to all enables you to jump to any file, type, member, or symbol declaration quickly.
You can use bookmarks to navigate quickly to specific lines of code in a file.
To set a bookmark, choose Edit -> Bookmarks -> Toggle Bookmark. You can view all the bookmarks for a solution in the Bookmarks window. To show bookmark window View -> Bookmark Window or CTRL + K, CTRL + W
Visual Studio 2019 provides on-demand formatting of your code file, including code style preferences, through the Code Cleanup feature. To run Code Cleanup, click the broom icon at the bottom of the editor or press Ctrl+K, Ctrl+E. Code Cleanup also applies selected code styles.
You can change the font face, size, and color that’s used for text in the IDE. For example, you can customize the color of specific code elements in the editor and the font face in tool windows or throughout the IDE.
To change the theme, Go to Tools > Options > Environment > General. In the Color theme list, choose the desired color theme.
To change the fonts, Go to Tools > Options > Environment > Fonts and Colors