5 things you need to know about .NET 5.

NET 5., the successor to .NET Core 3.1. And .NET Framework 4.8., Intends to bring a new cross-platform development experience to .NET developers. Offer. This brings new good features. Of course, in this article you will not learn everything about .NET 5., but you can focus on 5 to get a better understanding of what is happening.

Integrated platform

The first thing you need to know is that .NET 5. A new and integrated view of the .NET world. Brings to you.

If with .NET. If you have worked, you may be aware of the fragmentation of its platform since its first release in 2002. NET Framework. It was originally designed for Windows, but its runtime specification, also known as Common Language Infrastructure (CLI), was standardized as ECMA 335.

Standardization allows anyone to implement .NET runtime. Create. In fact, several of them appear on the horizon: Mono for Linux-based systems, Silverlight for browser-based applications, Micro frameworks, and .NET Compac. For mobiles and devices limited to resources, etc. Then Microsoft decided on .NET Core. Write from the beginning considering cross-platform compatibility.

These different implementations require an understanding of .NET packages. They created where they run from. Do you have to make different copies of your library to distribute it? The answer is NET Standard. Was. In other words if your libraries are for a .NET Standard. Specify, ensure that this implementation implements these specifications at all times.

You will find that it is not easy to achieve cross implementation compatibility in this busy situation. This is why .NET 5. appears on the scene.

New .NET platform. Integrated replacement of various .NET items. Is: .NET Framework., .NET Standard., .NET Core., Mono and so on. This is officially the next version of .NET Core 3.1. But basically the end of the .NET Framework., .NET Standard., And other versions that cause big trouble for .NET developers. It can be determined.

NET 5. Provides a common set of APIs that align various runtime implementations. This set of APIs is specified by net5.0 Target Framework Moniker (TFM), which is a token in the .NET project. Set to specify the target framework. Enables your applications to run a runtime implementation on any support. For example, to build any application that uses the Windows API, you must specify net5.0-windows TFM. That way, building a platform-specific application is your choice, not your choice of implementing the runtime you use to develop your application.

Of course, achieving this integrated platform required considerable effort and refinement of the interior architecture. As you will see later, some features have been removed from the main API suite, but the platform has reached an improved overall performance.

While the new .NET 5. is aimed at unifying the platform, the original program changed because of Corona. In fact, NET 5. is set up with the basics of integration, but will be completed with NET 6. in November 2021. With this version, you get stable release from the new global UI and support for specific TFMs, for example for Android (net6.0-android) and iOS (net6.0-ios).

New features in C#

The second thing you need to know about C#. NET 5. Comes with C# 9, a version of the original .NET platform programming language. There are several new features, but here are some important ones.

High level commands

Among the new features, one of the most important is the introduction of high-level commands. To learn what they are, take a look at the following program:

  1. using System;  
  3. namespace HelloWorld  
  4. {  
  5.     class Program  
  6.     {  
  7.         static void Main(string[] args)  
  8.         {  
  9.             Console.WriteLine("Hello World!");  
  10.         }  
  11.     }  
  12. }  

Just to write a string on the console, you need to define a namespace, a class, and a static Main() method. You can now get rid of this code infrastructure and easily write:

  1. System.Console.WriteLine("Hello World!");  

Top-level commands allow you to focus on what's really important in small console applications and applications, and use C # with more script-based approaches.

Record types

Another interesting and new feature is record types. With records, you can declare an immutable reference type, such as a class-based type that cannot be changed after creation. An example of an immutable type of internal reference is the System.String class. Once you have created an instance of System.String, you can no longer change its value.

Consider the following record type announcement:

  1. public record Person  
  2. {  
  3.     public string FirstName { get; }  
  4.     public string LastName { get; }  
  6.     public Person(string first, string last) => (FirstName, LastName) = (first, last);  
  7. }  

You can create a copy of Person record as you would a class, but you could not modify the FirstName property:

  1. var person = new Person("John""Doe");  
  3. person.FirstName = "Jack";    //throws an error  

However, you can easily compare two samples of Person record with initial values:

  1. var person = new Person("John""Doe");  
  2. var anotherPerson = new Person("John""Smith");  
  4. Console.WriteLine(person == anotherPerson);  //false  

Init setters

C# 9 also adds init access to define properties that can only be initialized. To better explain its uses, consider the definition of the following class:

  1. public class Person {  
  2.     public string FirstName { get; init; }  
  3.     public string LastName { get; init; }  
  4.     public string Address { getset; }  
  5. }  

This class defines a person with the LastName and FirstName properties that can be initialized but not changed. The Address property can be changed at any time.

  1. var person = new Person {  
  2.     FirstName = "John",  
  3.     LastName = "Doe",  
  4.     Address = "124 Conch Street, Bikini Bottom, Pacific Ocean"  
  5. }  
  7. person.Address = "17 Cherry Tree Lane";  
  8. person.FirstName = "Jack";    //throws error  

NET MAUI., Global user interface

Third, NET 5. brings you a new way to create cross-platform user interfaces. Thanks to the .NET Multi-platform App UI framework, also known as .NET MAUI, you can create user interfaces for Android, iOS, macOS, and Windows with a single project.

In fact, this feature is still in development and will be released with .NET 6., but you can look at NET MAUI. Get started to be ready for an official release.

NET MAUI. The evolution of Xamarin.Forms, an open-source framework for building Android and iOS applications with a single .NET code, can be considered. But the new framework proposes a global model for building user interfaces on desktop and mobile platforms.

Plus for the well-known NET MAUI model, Model-View-ViewModel (MVVM). Supports the new Model-View-Update (MVU) template. It is a one-way data flow template inspired by the Elm programming language architecture and provides an effective way to manage UI updates and program status.

Support for single file applications

The fourth thing you will get in .NET 5. is support for single file applications, ie applications that are published and deployed as a single file. This means that your application and all its dependencies are in one file. For example, run the following command in your .NET folder:

  1. dotnet publish -r linux-x64 --self-contained true /p:PublishSingleFile=true  

A file containing your program built for Linux, all the dependencies you used in your project, and .NET runtime. You receive. This means that you do not even need to install a .NET runtime. Do not have on the device.

Of course, you can also specify these parameters in your project configuration:

  1. <Project Sdk="Microsoft.NET.Sdk">  
  3.   <PropertyGroup>  
  4.     <OutputType>Exe</OutputType>  
  5.     <TargetFramework>net5.0</TargetFramework>  
  6.     <!-- Enable single file -->  
  7.     <PublishSingleFile>true</PublishSingleFile>  
  8.     <!-- Determine self-contained or framework-dependent -->  
  9.     <SelfContained>true</SelfContained>  
  10.     <!-- The OS and CPU type you are targeting -->  
  11.     <RuntimeIdentifier>linux-x64</RuntimeIdentifier>  
  12.   </PropertyGroup>  
  14. </Project>  

Note that this feature is similar to the approach for single-file applications that you can find in .NET Core 3.1. Build does not use. In .NET Core 3.1, a single-file program is just a way to package binaries. At runtime, their packaging is opened, loaded, and executed in a temporary folder. In .NET 5., the single file program has a new internal structure and runs directly without any performance penalty.

Technologies that are no longer supported

The last of the 5 things we learned about NET 5. is about things that are no longer supported. As mentioned above, examining the architecture and attempting to create .NET 5. As a cross-platform programming framework led to the removal of several features supported in the .NET Framework. It becomes. Let's take a quick look at the removed features and possible options.

Web Forms

For a long time, ASP.NET Web Forms has been the main technology for building dynamic web interfaces. However, everyone knows that its lifespan was close to the fate of the .NET Framework. .NET Core does not support Web Forms, so the fact is that it is no longer supported in .NET 5. It should not be.

However, we do have some alternatives to building web UIs. If you are building a traditional web application, Razor Pages is one of these alternatives. If you want to create one-page applications, you can use Blazor.

Windows Communication Foundation (WCF)

Even WCF, the common communication framework for Windows, is obsolete. This may come as a bit of a shock to developers who use it to build service-driven applications. However, if you realize that the main goal of .NET 5. is to become a cross-platform framework, this would be quite understandable.

The recommended alternative to WCF by Microsoft is to migrate to gRPC. But if you want to work with WCF or have a smooth transition, you can try the CoreWCF open source project.

Windows Workflow Foundation

Finally, NET 5. does not even include the Windows Workflow Foundation, the workflow engine technology in the .NET Framework. There is no official alternative to this technology. However, you can use CoreWF to transfer existing workflows in .NET 5. or to create new ones.


At the end of this article, you have a high-level idea of how .NET 5 works on existing .NET projects. It affects and what opportunities this new platform intends to give you. These 5 important points may seem small, but they allow you to talk about this milestone in the evolution of .NET. Find your way


The most important features of .NET 5 familiarity with .NET 5. NET publishing 5. NET training 5. new changes in .NET 5. advantages of .NET 5. NET evolution. The most important changes in .NET 5. New features of .NET 5. .NET 5
You must be logged in to post a comment