how to check variables in Visual Studio 2019 – C# and VB.Net
Checking the value of variables while debugging in Visual Studio is one of the best features of the IDE in my opinion! Let’s quickly go over the different ways you can view the values stored in variables at run time!
Time needed: 1 minute.
There are multiple ways to check the variable values depending on the type of variable.
For simple variables, such as strings and integers, you can hover over the variable in the IDE while the application is paused at a breakpoint and see the value in a tooltip.
- Data visualizer
For more complex variables, such as datatables, you will have to hover over the variable in the IDE while the application is paused at a breakpoint and then click the magnifying glass. This will bring up a window displaying the table data.
- Immediate Window
You can bring up the immediate window and type in “?variableName” and it will output the value of a variable. The immediate window has a lot of other uses too!
- Watch Window
The last method I show is the watch window. This window allows you to constantly track the value of variables as you step through code. This is the best option visually unless you are using complex data types such as Datatables!
I hope these methods help you debug your programs faster! These methods definitely help me out and I wanted to share them with everyone! Thanks for reading and if you have any recommendations that should be added to this list, let me know in the comments section!