22nd Sep 2021

Features of .NET 6 Preview


Written By, Jalpesh Nakum


Officially .NET 6 will be released in November 2021, but for the time being the Microsoft community has released 6 previews of .Net 6, which type of features are included in .NET 6.

All the features are not supported in the stable version of visual studio 2019, so here I have attached a demo that I performed in the visual studio 2022 preview version.

As per the preview released by Microsoft, we found some quite useful features that we are going to discuss here in this blog.


  • We all are aware of Collections and Collections are mainly of 2 types: Generic and Non-generic.
    In .NET 6 inside Generic Collections it means under System.Collection.Generic namespace we have a new collection is PriorityQueue <TElement, TPriority>.
  • Priority Queue is one type of Queue but with priority so for Insert or Remove element inside priority queue that time operations are the same.
  • For Inserting any value into PriorityQueue we will use Enqueue() operation and Removing any value we will use Dequeue() operation.

Now, we think this new collection is similar to Generic Queue so what are the differences between Queue<T> and PriorityQueue.

Mainly we have 2 differences between them.

  1. Enqueue: When we perform an Enqueue operation in PriorityQueue at that time we must specify the priority of each and every element.
  2. Dequeue: When we perform Dequeue operation in PriorityQueue at that time, first of all, removes that element that has lowest priority in the queue.



Hot reload with the Vs Debugger

  • Hot reload is a very useful process but sometimes when we change a little bit of code in our application and after applying that code we need to reload our application. That time Hot reload is a time-consuming process.
  • In .NET 6 we have a new button Apply Code Changes button that enables it when our application is running in the Browser, now we can easily apply our code when our application is running without restarting or reloading the application.


  • We know that DistinctBy is selector function which return those objects which generate unique results now in .NET 6 we will use in C# code.

Code : 



  • MaxBy and MinBy use for find maximum and minimum value depends on our condition.
  • When our condition is based on Int data type that time easily find maximum and minimum value but when condition based on String data type that time for MinBy first sort all records in alphabetical ascending order and same for MaxBy first sort sort all records in alphabetical descending order and return value.

Code : 



  • UnionBy method is used to combine the result-set of two or more SELECT statements and The UnionBy method selects only distinct values by default.
  • As above DistinctBy only returns those types of results which generate unique records so when we use UnionBy that time duplicate records are automatically removed, which are duplicate records it decided by our conditions.

Code : 


DateOnly and TimeOnly Struct

  • We are aware about DateTime, In .NET 6 DateOnly and TimeOnly are now used for displaying only Date part portion or only Time part portion.
  • We will use DateOnly whenever we want to display the only Date like leave days, birthdays and working days etc.
  • TimeOnly is used whenever we want to display the only Time like office time, alarm clocks and break time etc.
  • In .NET 6 both are provided in struct form.


  • Now, in .Net 6 Compression is supported in single file, to enable this feature we need to set the EnableCompressionInSingleFile property to true.
  • After enabling this feature files are automatically compressed at a runtime and provide huge space saving.

 Default font in windows form

  • This feature for windows form now we are able to set our default font as we want in our windows form by Add a single line of code in our program.cs file
  • We need to specify font style and font width in our program class as above and after that we easily change our default font in our windows form application.

Code : 

Output: output

Click here for the reference of above mentioned features https://github.com/yudiz-dotnet/dotnet-6-preview-features


.NET 6 Preview has truly arrived with a number of features, affecting low-level library features with source generators and analyzers. Hope you have enjoyed and are very curious about releasing this feature of .NET 6. Thanks for reading.

Written By,

.NET Developer at Yudiz Solutions Pvt. Ltd