Special Offer: My C#/.NET Bootcamp Course is out now. Get 10% OFF using the code FRIENDS10.

Are you curious about the new language features coming in C# 8? Great, me too. C# 8 will be available starting with the release of .NET Core 3.0 in September 2019.

If you want to take a look at the new features, you can install and use the .NET Core 3.0 Preview in Visual Studio 2019. Mads Torgersen, Design Lead for C# at Microsoft, writes in his article all the steps required to test the new C# 8 features.

In this video, I explain step-by-step how to set up Visual Studio and how to create your first project to use C# 8 features. Make sure to watch until the end, where I reveal one of the new C# 8 features.

Subscribe to my channel, if you do not want to miss a video:

Transcript

You want to test the new C# 8 features, but you don’t know how to get them? In this video, I’ll show you how to setup Visual Studio and how to create your first project to use C# 8 features. Make sure to watch until the end, where I reveal one of the new C# 8 features.

Introduction

Hi, I’m a Software Engineer with more than ten years experience on the .NET platform. If you want to learn more about software development and become a better developer, subscribe to my channel and turn on notifications.

First, we need to have an overview of what we need to install to make use of the new C# 8 features.

C# 8 can be used starting with the .NET Core 3.0 framework. .NET Core 3.0 is not yet available and set to release in September 2019. Luckily, there is a frequently updated Preview version available.

At the time of this recording, .NET Core 3.0 Preview 5 is available.

Mads Torgersen, Design Lead for C# at Microsoft, writes in his article that we need to install the latest Visual Studio 2019 Preview version to run the Preview of .NET Core 3.0.

Let’s recap. To use the new C# 8 features, we need to download and install the .NET Core 3.0 Preview 5 SDK and Visual Studio 2019 Preview.

.NET Core 3.0 Preview 5 Installation

Let’s get started by downloading and installing the .NET Core 3.0 Preview 5 SDK. We head to the official download page, and we selected the right SDK from the table. I choose the installer for my Windows machine.

The Windows SDK is about 127 MB, which takes a few seconds to download. After the download has completed, we launch the installer and start the installation, which only takes a few seconds.

Visual Studio 2019 Preview Installation

Next, lets head over to the Visual Studio 2019 Preview page and download the installer for the community edition.

Alright, let’s download the Community Edition of Visual Studio 2019 Preview. After the download has completed, we start the installation process, which takes up to 5 minutes on my machine.

It’s worth mentioning that you can run Visual Studio 2019 Preview side-by-side with any other Visual Studio version such as Visual Studio 2015, 2017, or 2019. The Preview version is a standalone version of Visual Studio which makes it extremely convenient to install, update, and uninstall the Preview version from your machine at any given time.

Let’s skip ahead until when the installation has completed.

After the first installation step, we see the familiar installation screen where we can include various workloads to be installed with our Visual Studio 2019 Preview installation.

Because we want to create a C# console application using the latest .NET Core framework, we choose the .NET desktop development and the .NET Core cross-platform development workloads which in total takes about 5 GB of space on the hard drive.

After pressing the install button, it takes another few minutes to install the selected workloads. Again, we skip ahead until the installation has completed.

When the installation has finished, we see the Visual Studio Installer screen where we see all the installed Visual Studio versions. I have Visual Studio 2017, 2019, and now also 2019 Preview installed.

Visual Studio 2019 Preview First Launch

Let’s press the launch button and start Visual Studio 2019 Preview for the first time. It’s possible that you get a message that your 30 day trial period has ended. We can fix that by clicking on the Check for an updated license button, and we’re good to go.

In the new Visual Studio 2019 start dialog, we select Create a new project on the bottom right of the screen and create a new Console Application for .NET Core. Name the project and click on the create button to create the project and launch Visual Studio 2019.

Verify .NET Core 3.0 SDK Installation

Let’s open the Package Manager Console to verify whether the .NET Core 3.0 SDK has been installed. You find the Package Manager Console in the View menu within the Other Windows submenu.

We type dotnet –list-sdks to get an overview of all the installed .NET SDKs. If the installation has worked as expected, you should see the 3.0-preview5 version listed below the latest 2.1 SDK version.

Verify Project Settings

Now let’s make sure our project uses the correct target SDK. Right click on the project to open the project settings, and as we can see the project correctly uses .NET Core 3.0 as its target framework.

Test if C# 8 works

Let’s see if everything is set up by using a C# 8 feature.

One of the new C# 8 features allows us to create using statements like variable definitions. It allows us to skip the curly braces. Let’s see if it works in Visual Studio 2019 Preview.

We start the build, which is successful.

Now let’s compare this with a project created in the stable Visual Studio 2019 version targeted to use .NET Core 2.1 SDK.

As we can see we get a compiler error stating that this feature is not available in the current project.

Summary

In this video, we’ve learned how to set up our machine to use C# 8 features by installing the .NET Core 3.0 SDK Preview 5 and Visual Studio 2019 Preview.

You find all the important links in the video description below. Don’t forget to hit the like button and subscribe to the channel. In the next videos, I’ll show you all the new C# 8 features.

Thanks for watching and see you in the next.

 

Claudio Bernasconi

I'm an enthusiastic Software Engineer with a passion for teaching .NET development on YouTube, writing articles about my journey on my blog, and making people smile.