C# 15 is scheduled for release alongside .NET 11 in November. Developers can now explore its new features through .NET 11 preview 7. Key additions include union types, closed hierarchies, an initial preview of an updated unsafe model, collection expression arguments, extension indexers, and labeled break and continue statements.
Union types allow developers to explicitly define the exact set of types a value can hold within the type system. Unlike object, marker interfaces, or abstract base classes, which permit any derived or implementing type at runtime, union types constrain values to a specified set of case types that are not necessarily related by inheritance. This provides more precise type control and enables exhaustive switch expressions without a discard or default arm, as the compiler knows the complete set of possibilities.
Closed hierarchies extend the concept of explicit type definition to class hierarchies. Applying the 'closed' modifier to a class makes it implicitly abstract and restricts its direct derived types to the declaring assembly. This allows developers to declare precisely which subtypes are permitted, rather than leaving derivation open-ended. This feature, along with union types and planned closed enums, aims to express the allowed set of shapes directly within the type system.
The introduction of union types and closed hierarchies represents a broader design philosophy in C# 15: making the allowed set of types explicit. These features provide developers with more robust tools for defining and enforcing type constraints, leading to more predictable and maintainable codebases. The updated unsafe model also signals ongoing evolution in how C# handles low-level operations.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
C# 15, set to release with .NET 11 in November, is now available in .NET 11 preview 7, introducing features like union types, closed hierarchies, and an updated unsafe model. These additions enhance type system expressiveness and control over inheritance, impacting how developers define and manage data structures.