Skip to main content

Latest C# 8 features unfolded with preview version

In the journey of about 20 years, C# has been evolved to become one of the best languages in the world. C# is consistently in the top list of most used and most loved languages. With Microsoft's move to make .Net framework and C# language open source it opened new doors to the future. Contributors around the world are adding value by suggesting new features and helping to make it a reality. You can also become a contributor or can get in-depth knowledge about the language by exploring source code.

Recently Microsoft has released few C# 8.0 features along with release of Visual Studio 2019 Preview and .Net Core 3.0 preview. In this post we will explore these features in detail.

Prerequisites

Before we jump in, you need to install some latest updates on your system to get started. So first you need to download and install .Net Core 3.0 Preview 1 and  Visual Studio 2019 Preview 1. While installing Visual Studio 2019 don't forget to select ".Net cross-platform development" option. What if you forgot? Don't worry, you can modify it by opening Visual Studio installer later.

Once you have all the installations done, open Visual Studio 2019 Preview and create new project with type "Console App (.Net Core)".

After Visual Studio is done with project creation, you need to change target framework of Project by right clicking on the Project in Solution Explorer and click on Properties and navigate to Application tab and select to .NET Core 3.0.



Then you need to navigate to Build tab and click on Advanced button and modify Language Version to "C# 8.0 (Beta)".



Now you are ready to get going!

Features

The features are discussed in detail in below blog posts.
1. Nullable reference types
2. Ranges and indices
3. Asynchronous streams

Wrapping up

Now that you have reached so far, try some of these features, add your own scenarios. You can find source code for all the feature in Github here. Leave your comments, your suggestions and feedback. I would love to hear from you. I will keep on posting other exciting features when they will be out and any other interesting topics.

Read more with below references if you are more interested into these features.


References
A blog by Mads Torgersen
Video by Meds Torgersen
Nullable Reference Types


Happy Coding!

Sandeep Patil | The Programmer

Comments

Popular posts from this blog

C# 8.0 feature - Nullable reference types

This blog post is part of series of latest C# 8.0 features . In this post we will explore in detail about the new feature Nullable reference types. Well you read it right! Till now reference types were by default nullable i.e. they can hold null value. But that increases the chances for null reference exceptions. Not every time developers handled it correctly or it could be some other assembly or API not behaving correctly which causing your code to throw an exception. With C# 8.0 nullable reference types compiler will warn you about unsafe behavior of code and possible occurrences of any possible dereferences of null reference. You can only assign null to variable if it is nullable. Lets look at the below code snippet. Compiler is not showing any warnings or errors. But if you try to run the application it will throw null reference exception. In this scenario it is straightforward but in real life you might be receiving data from other assembly or API that could return you bad d...