C# 15 Brings Union Types, Closed Hierarchies, and Improved Memory Safety
Microsoft has announced that it will release C# 15 in November. The new version includes several features, including union types and closed hierarchies. Union types allow developers to categorize different custom data types into a single entity, providing better pattern matching and protection against rogue data types.
The unsafe keyword is also being expanded to inform callers of obligations that must be discharged to maintain safety. This change follows the lead of Rust and Swift, where the keyword has stricter, propagation-oriented semantics.
Other new features in C# 15 include collection expression arguments, which allow developers to pass parameters directly to the underlying collection's constructor within the collection expression syntax.