Closed class hierarchies: Exploring the .NET 11 preview - Part 4 0 ▲ Andrew Lock | .NET Escapades 149 days ago · 13 min read2542 words · Tech · hide · Fediverse post This is the fourth post in the series: Exploring the .NET 11 preview. Part 1 - Running background tasks in Blazor with Web WorkersPart 2 - .NET (OK, C#) finally gets union types🎉Part 3 - Avoiding ToString() allocations with StringBuilder.MoveChunksPart 4 - Closed class hierarchies (this post) In this post I look at the implementation of closed class hierarchies that is available in .NET 11 preview 5. I'll describe what a close closed hierarchy is, how to create one, and discuss why you might want to. What is a "closed class hierarchy"? A closed class hierarchy is a class hierarchy that can only be defined within a single assembly. Attempting to derived from a closed class from a different assembly is a compilation error. This is easiest to see in action. Imagine you have the following classes, all in the same assembly: // Create a closed base class public closed class Animal { } // Each class derives from the closed Animal class public class Dog : Animal { } public class Cat : Animal… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town