Skip to content
Note

ReadOnlySet<T> is coming in .NET 9

ReadOnlySet is coming in .NET 9

Say goodbye to issues with IReadOnlySet interface. No more casting back to mutable sets or creating custom read-only sets!

The latest Preview 6 version brings this new type.

I often prefer ISet above IList in Domain Driven Design.

Why? Because they guarantee unique elements in the collection.

It is often a requirement to prevent duplicate elements and ISet is perfect for this. Also, it comes with some nice methods to compare, merge, and create Subsets.

Earns Its Keep

Every Sunday, one post on Dataverse, .NET, and whether the tools we rely on still deserve to be there.