Visual Studio is a fully packed IDE for .NET development. With numerous built-in tools covering coding, build, debug, deploy, collaboration and analysis. You can use it to create anything you can in .NET including Web APIs, Mobile apps, desktop applications, console applications and a few others. There are 3 main languages which fall under the banner of .NET: C#, F# and Visual Basic.
Which language should I learn?
C# is the most common of the .NET languages. If you have written C, C++, Java, or TypeScript then you are part way there. It is an object-oriented strongly typed language. Previously one of the most popular languages out there (now falling behind the likes of Python) it is a great one to have on the CV.
Visual Basic with .net progressed from the original Visual Basic but now uses the .net framework. Compared to C# Visual Basic tends to be more human readable and has a simple syntax. If you are coming from creating VBA and macros in Microsoft Office, then you will be at home.
F# is the newest of the three languages and is a rather interesting one. Instead of being based on a language which has been out there a long time (like VB or C++) it is a mixture of the best of a few languages. Like Python it uses indentation rather than brackets for structure but as it runs on the .net framework it gives you the same level of performance as C#. If you are from a Python background it may feel like a steppingstone.
If you aren’t sure which language to start with then I would recommend C#. It is the most desired of them all and you can carry out basic to highly complex applications.
So, what is Visual Studio Code?
You may have heard of Visual Studio Code or might even already be using it and wonder what the differences are. Both products are for development, and both are made by Microsoft. Visual Studio has been around a lot longer than Visual Studio Code. They are two quite different products with different purposes. Visual Studio is built with the purpose of .NET development and the whole IDE is built to support this. You can install packages, edit MS SQL server databases etc.
So why should you bother with Visual Studio rather than just stick with Visual Studio Code? The quick answer is the development experience. Visual Studio was purposefully created for .NET development with a simple IDE which also allows some drag and drop. Some still use Visual Studio Code for C# development but you will find you need to enter lots of commands in the terminal which are just on menus in Visual Studio.
Installing Visual Studio
Before we look at jumping in and getting things installed then the different versions are worth a quick mention. We won’t go into lots of detail here, but the quick version is that Visual Studio Community is free and will meet most of your needs, especially as a beginner. The Professional and enterprise versions have additional functionality like additional testing tools, cross-platform development etc. If you are interested in the differences, then you can compare them here.
We will focus on getting up and running with the free community edition. Head over to the download page of the Visual Studio website and click on the Free download button under Community. You will notice the download is very fast, though don’t be fooled it will only be the installer.
The Visual Studio installer isn’t as simple as clicking next and accept. Firstly, you might be prompted to install the installer. I find it best not to even ask why you downloaded an installer, to download an installer to install Visual Studio if not you may cause a black hole to appear.
Hopefully you will have now made it to the actual installer:
You will notice there are a lot of options to look at here. The easiest way to select what you need is to just stick to the Workloads screen. For this demo we are only going to create a simple console app which means you will need the .NET desktop development workload pack. Just check the box and you are ready. By default, all the standard components for C# will be installed. You can use the Installation details area on the right if you want more control over what is installed. For now, we are just going to continue with the defaults.
If you are planning on developing Web APIs, games, data science and the other features of Visual Studio you can add those workloads here. The installer will build up a list of components installed in the background. The good news is that you can re-run the installer at any time to add and remove components, so don’t worry about installing everything now (especially because it can take a while).
Once you have selected what you need (if you are following along .NET desktop development as a minimum) then click on install. You will now need to wait for all the packages to be downloaded and installed. Depending on your internet connection this may take a while so best to grab a coffee. Once Visual Studio starts you will be asked to sign in, create and account or skip. One of the benefits of having an account is that your settings will automatically be brough across devices. If you want to hurry up with the tutorial just select Skip this for now, you can easily sign up later. You can then pick you development settings and theme. I always leave it as General, and I prefer the Dark theme, but the choice is yours. Finally, you will be in!
Building a quick console app
Now you have Visual Studio running let’s create a basic Hello World console app just so you can get a flavour. After getting set up and every time you start Visual Studio you will be presented with the welcome screen. This allows you to open projects, clone repos, create new projects and a few other options. So we can get started with our console app then select Create a new project to start the wizard.
The first step is to select the project type, you should find Console App in the list, if not you can start entering it into the search box at the top. Select it and click Next. On the next step we need to give our project a name and a home. For the name enter HelloWorld and leave the default location and select Next.
The next step you will be asked to choose a framework, you can just leave the default and click on Create. Your project will now be generated and will show in the main Visual Studio window.
It is likely by default that Visual Studio will have already created a Hello World console app for you! If not, then you can simply copy and paste the below into the program.cs file:
To try out your application click on the play button in the top toolbar or if you are on Windows press F5.
Your application will now compile and execute. Assuming it was successful you should have a new window open and “Hello, World!” printed on the top line. You can now press any key to close the window.
You have now taken your first small step towards using Visual Studio! 🥳
This post includes icons from icons8.com.