Started development of .NET 8.0

📆

👤

At November 23, Microsoft started development of the next LTS version of .NET which is to be released at November 2023 according to the planned schedule shown below:

Taken from .NET support policy

In the same month, .NET 7.0 was released at November 8th of this year, which means that not even 30 days has passed (15 days to be exact) and .NET 8.0 has already made an appearance at GitHub.

The first feature that was slated to appear in the next LTS version of .NET is the frozen collections. To summarize this article, the frozen lists and frozen dictionaries are implemented as an alternative to immutable lists and dictionaries.

If you have this pre-alpha version of .NET (8.0.100-alpha.1.22570.9) installed on your system, you can make your frozen dictionaries and lists be calling the ToFrozenSet() function, as shown in this example:

var normalList = new List<int> { 1, 2, 3 };
var readonlyList = normalList.AsReadOnly();
var frozenSet = normalList.ToFrozenSet();
var immutableList = normalList.ToImmutableList();

normalList.Add(4);

Console.WriteLine($"List count: {normalList.Count}");
Console.WriteLine($"ReadOnlyList count: {readonlyList.Count}");
Console.WriteLine($"FrozenSet count: {frozenSet.Count}");
Console.WriteLine($"ImmutableList count: {immutableList.Count}");

Executing this code will result in:

List count: 4
ReadOnlyList count: 4
FrozenSet count: 3
ImmutableList count: 3

The frozen dictionaries and lists don’t get updated when the regular list updates by either adding, editing, or removing elements, like the immutable lists and dictionaries. However, there is a major difference between the two.

Frozen dictionaries and lists are actually Sets, which means that in order for dictionaries and lists to be frozen, they would have to get rid of duplicates, as Sets can’t have duplicate entries. Currently, as of this pre-alpha build shown above, .NET 8.0 has implemented the two frozen collections:

These frozen collections actually have performance benefits, as they are faster than the regular lists. You can see the progress here.


Discover more from Aptivi

Subscribe to get the latest posts to your email.

Thoughts?

Subscribe to our newsletter?

Subscribe today to get new articles instantly delivered to you!

Not now

Design a site like this with WordPress.com
Get started