Click here to Skip to main content
15,741,581 members
Articles / Programming Languages / F#
Posted 29 May 2022

Tagged as


4 bookmarked

.NET 6 - New Features

Rate me:
Please Sign up or sign in to vote.
2.38/5 (6 votes)
29 May 2022CPOL7 min read
What's new in .NET 6
In this article, you will learn about the various new features of .NET 6.


On 8th November, 2021, Microsoft announced a new version of .NET called .NET 6. According to Microsoft, it the "fastest .NET yet" and this version has LTS (long time support version) of 3 years.

Basically, .NET 6 is more focused on the C# and F# languages and they have introduced C# 10 and F# 6 with this release, which will make our code simpler, faster and better than older versions of .NET. This version is available for the Linux, Mac and Windows platforms.

Let's drive through the features of this release of .NET version.


This is the main and noticeable change in these features. .NET 6 has worked on a lot of functionalities to make them better, but we will cover three of them now.

File Stream

In .NET 6, System.IO.FileStream namespaces and all its classes are almost re-written. That makes this class faster and more reliable than the previous one.

Now, file stream will not block asynchronous I/O operations on Windows. There are few examples.

In .NET 5, the getlength() method from fileStream namespace takes 1,932 ns to execute whereas in .NET 6, it takes only 58.52 ns to execute. So as you can imagine, it is now multiple times faster. The same thing can be experienced on Mac and Linux environments.

JIT compilationimagine

.NET 6 has made performance-related changes in JIT compilation technique. Basically, JIT works on Profile Guided Optimization (PGO) technique where it optimized the compile code, but in .NET 6, they have introduced Dynamic Profile Guided Optimization (DPGO), in which optimized code is generated by the JIT compiler. However, this time it works with the tired compilation to more optimized code based on tier 0. DPGO is disabled by default - you need to enable it to use this feature.

Crossgen2 Introduction

.NET 6 has introduced Crossgen 2, that helps to generate and optimize native code in a faster way. Crossgen 2 is re-written in C# instead of C++.

With this improved version of Crossgen, the analysis and optimization of native code is possible, so it boosts up the startup time of the application.

For those who don't know about Crossgen, here is a small introduction.

What is Crossgen?

Crossgen is a tool that provides an earlier compilation of code before the actual JIT works, so the JIT time can be reduced. Basically it runs above all assemblies and stores the compiled code in a separate section. Then, that compiled code is fetched quickly at runtime. It helps in faster startup for application.

Crossgen2 was introduced to come over the limitation of Crossgen, which was only able to produce native code of one thing at a time.

Support ARM64

.NET 6 now supports ARM64 based processors and operating systems in Mac and Windows. This means from now, it supports both X64 ARM and 64-bit OS.

For those who don't know about ARM OS, here is a small introduction.

Basically, ARM is a different CPU architecture like X86(32 bit) and X64(64 bit) for Windows, but this architecture was developed for mobile and smart devices.

ARM64 is the next version of ARM architecture that supports 64-bit processing.

Hot Reload

This feature is very useful for developers. They can modify and instantly apply those changes to your running application. It will help them to increase the development process, basically this feature helps to reduce the time between number of edits and application compilation. All application development types are supported by this feature like web, desktop, mobile development, cloud and other project types. But make a note that this feature will not be supported in Xamarin forms and applications that build using F#.

The Hot Reload icon is shown in Visual Studio using a fire like symbol. This feature not only helps to apply code changes instantly, but alsohelps to restart application faster.

Additionally, this feature also introduces Hot Reload on Save functionality where, upon clicking the Save button, the application will automatically hot reload and apply saved changes. It is important to note that this feature is optional and we can turn it off at any time.


MAUI is also known as .NET multi-platform app UI. This feature has just been introduced and is in the preview stage. With this feature, developers can use a single code base and developed application (client apps) for desktop and mobile. .NET MAUI uses native container and controls for Blazor hybrid scenarios.

C#10 and Its Related Features

With .NET 6, C# 10 and its related features are also included. In these .NET features, C# has been modified and upgraded to use some new language features like:

  • sync main method
  • target typed new expression
  • file scoped named space
  • Nullable reference type

Here, one thing to be note is that your existing C# code or functionality will not hamper after upgrading to .NET 6.

F# Improvements

The following new improvements can be found in C#:

  • native .NET task support
  • indexing syntax made more simpler with expr[idx]
  • "as" pattern
  • revision on indentation syntax
  • binary number format
  • changes in NativePtr


HTTP/3 is the new version of HTTP. In this new version, HTTP uses QUIC protocol, which is used as a underlaying connection protocol.

This protocol helps in establishing a connection more quickly and independent of IP address. It also allows mobile and smart devices to roam between WIFI and other wireless networks, before this version http is using HTTP/1.1 and HTTP/2.

HTTP/3 improved a connection request even when there is small amount network packet.

System.Text.Json API Improvements

There are lot of improvements done in JSON API, some of them are as follows:

New Source Generator

.NET 6 introduced a new source generator for System.Text. JSON, now source generator is working with JSON sterilizer and can be configured in multiple ways. It helps to speed up the performance, reduce memory consumption.

**For who those don't know about source generator (SG), it is a C# compiler feature that generates new C# source files on the fly that are added to the compilation.

Writable DOM

This is the new lightweight serialization alternative when the use of a plain CLR object is not possible. It helps us to navigate through large JSON tree and read a node.

The following types are supported by new serialized writeable DOM:

  • JsonNode
  • JsonArray
  • JsonValue
  • JsonObject

Use of IAsyncEnumerable in JSON

The serialization and deserialization of IAsyncEnumerable <T> is now possible with .NET 6.

IAsyncEnumerable types can be serialized as a JSON array and for deserialization, a new method is used (JsonSerializer.DeserializeAsyncEnumerable).

Below are the newly added serialization interfaces:

  • IJsonOnDeserialized
  • IJsonOnSerialized
  • IJsonOnDeserializing
  • IJsonOnSerializing

Security Improvements

.NET 6 has also put some improvements in security: it now comes with Control-flow Enforcement Technology and write exclusive execute.

Write exclusive execute(W^X)

This security aspect blocks simple attack paths by avoiding writeable and executable memory pages at a time.

Control-flow Enforcement Technology (CET)

Basically, CET (control flow technology) is introduced by Intel and it helps us to protect from control flow hijacking attacks. .NET 6 also provides support for x64 apps.

Unused Assemblies Trimming

Basically, this functionality is already introduced in .NET 5 where it helps to trim unused assemblies, but in .NET 6 the functionality is upgraded to unused types and members too. Moving forward, unused types and members are also trimmed.

Improvements for Windows Form

Application.SetDefaultFont(Font) is new method introduced by .NET 6, as the name suggests, it sets the default font to the win-form.

In addition to this, C# Windows Form been updated to give support to using directives, file scoped namespace, and nullable reference.

New Target Framework

New target framework has been introduced in .NET 6. Now you can see net 6.0-android, net 6.0-ios, and net 6.0-macos in target framework.

New API Related to LINQ

.NET 6 has released new LINQ related API like:

  • Enumerable.TryGetNonEnumeratedCount - get number of elements in a sequence
  • Enumerable.Chunk - break the sequence elements into chunks
  • Enumerable.MaxBy - find max element using key
  • Enumerable.MinBy - find min element using key


.NET compatibilities and supported versions are as follows:

  • .NET 6 is supported on VS 2022 that is Version 17

.NET 6 is released with the following runtime support:

  • .NET Runtime 6.0.0
  • ASP.NET Core Runtime 6.0.0
  • .NET Desktop Runtime 6.0.0
  • .NET 6 does support the following languages:
    • C# 10.0
    • F# 6.0
    • Visual Basic 16.9

Points of Interest

If your application was build on legacy .NET framework, then it will take more effort to migrate it to 6.x.

I hope this article will give you an idea about what's new in .NET 6. In the next article, we will see more about C# 10.

Suggestions and queries are always welcome.

Thanks for reading!


  • 30th May, 2022: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead
India India
Hi there, I am Prasad. Author, Blogger, contributor and passionate about Microsoft .NET technologies. I like to write an articles/blogs on different .NET aspects and like to help Developers, to resolve their issues and boost them on Microsoft Technologies.

Certifications: Microsoft Certified professional (MCP), Microsoft Certified technology specialist (MCTS), Agile-Scrum Master.

Awards: Microsoft Re-connect MVP (GSC Member), Most valuable member at dotnetspider, Most popular curator, Most active curator, featured curator at Microsoft Curah, Editor at dotnetspider.

Microsoft MVP 2014 [ASP.NET/IIS]
Click here for more .NET Tips
-After all Knowledge is an endless entity

Comments and Discussions

Questiongetlength() method in Filestream Pin
gaurav.siet5-Jul-22 2:36
gaurav.siet5-Jul-22 2:36 
SuggestionNice one but I'd love to learn more about each subject Pin
Unuvar Bek30-May-22 23:13
Unuvar Bek30-May-22 23:13 
QuestionThe article has good content, but... Pin
Paulo Zemek29-May-22 21:36
Paulo Zemek29-May-22 21:36 
Go back and search for things like "namespces namesapce".
I found those 2 words at the beginning of the article, and it gave me the impression of a poor article just because of the mistypes. Please, fix those, and then people will be able to focus on the actual contents of the article.

AnswerRe: The article has good content, but... Pin
koolprasad200329-May-22 22:40
professionalkoolprasad200329-May-22 22:40 
GeneralRe: The article has good content, but... Pin
Paulo Zemek29-May-22 22:49
Paulo Zemek29-May-22 22:49 
AnswerRe: The article has good content, but... Pin
koolprasad200329-May-22 23:10
professionalkoolprasad200329-May-22 23:10 
GeneralRe: The article has good content, but... Pin
James McCullough31-May-22 2:41
professionalJames McCullough31-May-22 2:41 
GeneralRe: The article has good content, but... Pin
JaredThirsk1-Jun-22 23:29
JaredThirsk1-Jun-22 23:29 
GeneralRe: The article has good content, but... Pin
JaredThirsk1-Jun-22 23:31
JaredThirsk1-Jun-22 23:31 
GeneralRe: The article has good content, but... Pin
koolprasad20038-Jun-22 18:47
professionalkoolprasad20038-Jun-22 18:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.