Learn how to get started with Microsoft Visual Studio to edit, debug, build code, and publish an app for your projects.
This article will introduce you to the absolute basics of using the popular Microsoft IDE, Visual Studio. By the end of the article, you should be set up and ready to start writing your own software for your projects.
Installing Visual Studio
The setup procedure is straightforward, but there are a few things worth mentioning. After initializing the installer, select the version you want to install:
The Visual Studio installation window.
Enterprise is for large(r) teams and companies, Professional is the version for small(er) teams and Community is a free variant for individuals. After choosing a version, select the components you want to install:
The different options for Visual Studio.
This depends on what you want to develop. If you are new to Visual Studio, I recommend you stick to the options in the Workloads tab. However, if you know what youâre doing, or youâre feeling particularly ambitious, you can select and deselect options in the Individual Components tab. After youâre done, start the download by clicking Install:
Select your version of Visual Studio.
This shouldnât take too long, Once the installation is complete, youâll receive this message:
A successful installation of Visual Studio.
Launching Visual Studio for the First Time
After you complete setup and installation, go ahead and launch the application. Youâll get asked whether you want to login to other services like GitHub or Azure. This is completely optional and you can completely skip this step. Upon logging in and choosing a design, you should see a window similar to this:
To get started, choose File, then New, and Project. A dialogue should pop up thatâll allow you to create a new project:
Choose the programming language you want to use on the left-hand side of the window.
The middle section of the window shows the available templates for your selected project type. You can enter a name, a path, and some programming languages, which will allow you to choose a compiler/interpreter version.
Click Ok to create your new project.
Once you've set the parameters of your project, you'll be taken to this window.
How to Write Code in Visual Studio
When you first start Visual Studio, the UI can look intimidating. However, writing programs works similarly to a simple text-editor. However, there are a few features thatâll increase your productivity and code quality.
The first thing you may notice is this suggestion that pops up that when you start typing a command:
Visual Studio will provide suggestions as you type commands.
You can use the auto-completion to quickly insert the highlighted command by hitting the enter key. Some constructs, like the for-loop, allow you to add a complete template by pressing the tab key twice. The green and yellow bars next to the line-numbers indicate saved and modified code.
A similar helper tool shows the documentation of a function while you type its name:
A helper tool is another way to check the documentation of a function.
You can use the up and down keys on your keyboard to display different method variants.
Debugging in Visual Studio
You can set a breakpoint by clicking the gray area left of the line numbers. To remove a breakpoint, click the red circle that appears:
Now, when you execute the program, it will stop at the breakpoint. This allows you to debug it. To check a variableâs value, hover the mouse cursor over the variable and a small pop-up should appear:
Use the cursor to check a variable's value.
Click the pin-needle to prevent the pop-up from disappearing. This allows you to inspect how a fieldâs value changes over time, e.g., in a loop. Some variables like objects and arrays, allow you to check each value they hold. You can also change the variableâs value by double-clicking the pop-up.
To continue your program, use the tools in the main menu bar:
The tools in the main menu bar will help you continue your project.
Alternatively, you can also press F5 to continue the execution, Shift + F5 to stop debugging, F11 to step into a statement, F10 to step over it and Shift + F11 to step out of it. You can also add and remove existing breakpoints while debugging.
Visual Studio is Free and Worth Giving a Try
Visual Studio is a really powerful IDE and, because thereâs a free version available, itâs totally worth testing out. It may look a bit intimidating when you first see it, but itâs easy to dive in a get familiar with its features.
Arduino Programming in Visual Studio
Plugins are available for Visual Studio, including some that allow you to utilize Visual Studio to program and debug your Arduino projects. Check out my tutorials about programming Arduino in Visual Studio here: