What's new in .NET 5 - .NET (2024)

  • Article

.NET 5 is the next major release of .NET Core following 3.1. We named this new release .NET 5 instead of .NET Core 4 for two reasons:

  • We skipped version numbers 4.x to avoid confusion with .NET Framework 4.x.
  • We dropped "Core" from the name to emphasize that this is the main implementation of .NET going forward. .NET 5 supports more types of apps and more platforms than .NET Core or .NET Framework.

ASP.NET Core 5.0 is based on .NET 5 but retains the name "Core" to avoid confusing it with ASP.NET MVC 5. Likewise, Entity Framework Core 5.0 retains the name "Core" to avoid confusing it with Entity Framework 5 and 6.

.NET 5 includes the following improvements and new features compared to .NET Core 3.1:

  • C# updates
  • F# updates
  • Visual Basic updates
  • System.Text.Json new features
  • Single file apps
  • App trimming
  • Windows Arm64 and Arm64 intrinsics
  • Tooling support for dump debugging
  • The runtime libraries are 80% annotated for nullable reference types
  • Performance improvements:

.NET 5 doesn't replace .NET Framework

.NET 5 and later versions are the main implementation of .NET going forward, but .NET Framework 4.x is still supported. There are no plans to port the following technologies from .NET Framework to .NET 5, but there are alternatives in .NET:

TechnologyRecommended alternative
Web FormsASP.NET Core Blazor or Razor Pages
Windows Workflow (WF)Elsa-Workflows

Windows Communication Foundation

The original implementation of Windows Communication Foundation (WCF) was only supported on Windows. However, there's a client port available from the .NET Foundation. It's entirely open source, cross platform, and supported by Microsoft. The core NuGet packages are listed below:

The server components that complement the aforementioned client libraries are available through CoreWCF. As of April 2022, CoreWCF is officially supported by Microsoft. However, for an alternative to WCF, consider gRPC.

.NET 5 doesn't replace .NET Standard

New application development can specify the net5.0 Target Framework Moniker (TFM) for all project types, including class libraries. Sharing code between .NET 5 workloads is simplified: all you need is the net5.0 TFM.

For .NET 5 apps and libraries, the net5.0 TFM combines and replaces the netcoreapp and netstandard TFMs. However, if you plan to share code between .NET Framework, .NET Core, and .NET 5 workloads, you can do so by specifying netstandard2.0 as your TFM. For more information, see .NET Standard.

C# updates

Developers writing .NET 5 apps will have access to the latest C# version and features. .NET 5 is paired with C# 9, which brings many new features to the language. Here are a few highlights:

  • Records: Reference types with value-based equality semantics and non-destructive mutation supported by a new with expression.

  • Relational pattern matching: Extends pattern matching capabilities to relational operators for comparative evaluations and expressions, including logical patterns - new keywords and, or, and not.

  • Top-level statements: As a means for accelerating the adoption and learning of C#, the Main method can be omitted, and an application as simple as the following example is valid:

    System.Console.Write("Hello world!");
  • Function pointers: Language constructs that expose the following intermediate language (IL) opcodes: ldftn and calli.

For more information on the available C# 9 features, see What's new in C# 9.

Source generators

In addition to some of the highlighted new C# features, source generators are making their way into developer projects. Source generators allow code that runs during compilation to inspect your program and produce additional files that are compiled together with the rest of your code.

For more information on source generators, see Introducing C# source generators and C# source generator samples.

F# updates

F# is the .NET functional programming language, and with .NET 5, developers have access to F# 5. One of the new features is interpolated strings, similar to interpolated strings in C#, and even JavaScript.

let name = "David"let age = 36let message = $"{name} is {age} years old."

In addition to basic string interpolation, there's typed interpolation. With typed interpolation, a given type must match the format specifier.

let name = "David"let age = 36let message = $"%s{name} is %d{age} years old."

This format is similar to the sprintf function that formats a string based on type-safe inputs.

For more information, see What's new in F# 5.

Visual Basic updates

There are no new language features for Visual Basic in .NET 5. However, with .NET 5, Visual Basic support is extended to:

Descriptiondotnet new parameter
Console Applicationconsole
Class libraryclasslib
WPF Applicationwpf
WPF Class librarywpflib
WPF Custom Control Librarywpfcustomcontrollib
WPF User Control Librarywpfusercontrollib
Windows Forms (WinForms) Applicationwinforms
Windows Forms (WinForms) Class librarywinformslib
Unit Test Projectmstest
NUnit 3 Test Projectnunit
NUnit 3 Test Itemnunit-test
xUnit Test Projectxunit

For more information on project templates from the .NET CLI, see dotnet new.

System.Text.Json new features

There are new features in and for System.Text.Json:

  • Preserve references and handle circular references
  • HttpClient and HttpContent extension methods
  • Allow or write numbers in quotes
  • Support immutable types and C# 9 Records
  • Support non-public property accessors
  • Support fields
  • Conditionally ignore properties
  • Support non-string-key dictionaries
  • Allow custom converters to handle null
  • Copy JsonSerializerOptions
  • Create JsonSerializerOptions with web defaults

See also

  • The Journey to one .NET
  • Performance improvements in .NET 5
  • Download the .NET SDK
What's new in .NET 5 - .NET (2024)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6266

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.