You may have noticed that the word “Framework” was omitted in the headline. Gone are the days of frameworks. Why? Well, .NET 5 combines .NET Core with .NET Framework to create a unified environment and a unified output for all things .NET and .NET Core related.

We live in exciting times!

Merged platforms

Microsoft has always had a unified platform vision of a unified .NET ecosystem. This means that you will be able to use one set of APIs or tools that target a broad set of application types. You are now able to literally pick the parts of the .NET platform that you’d like to use, without the need to install unnecessary .NET features.

C# 9 changes

.NET 5 includes C# 9 as well as F# 5. Here are a few C# 9 features to look forward to.

C# - Logical patterns

With C# 9 you can combine patterns with logical operators. These are: and, or and not. Do not be confused with the operators! Here is an example of what I mean:

Student s when s.Age switch
{
    >= 18 and <= 80 
},

Student in the above example is a class and Age is a property of it. Here the code combines two relational patterns.

C# - Records

C# 9 includes records. This enables the whole object to be immutable and behave like a value. With the help of the data keyword, the class can be marked as a record giving the class additional value-like behaviors. Here is a small example of a Record:

public data class Student
{
    public string FirstName { get; init; }
    public string LastName { get; init; }
    public string CourseName { get; init; }
    public int Age { get; init; }
}

.NET 5.0 Target Framework

A project that targets .NET 5 will have a project file that looks similar to the following:

net5.0 will combine and replace netcoreapp and netstandardTFMs (Target Framework Moniker) and it will support .NET Framework Compatibility mode.

More to come

There are a lot more changes in .NET 5, so in a follow-up I'll discuss more of them.






This article was originally published on December 11, 2020