[MS] Explore new features available in C# 15 preview - devamazonaws.blogspot.com
C# 15 will ship with .NET 11 in November. All the new features are available in .NET 11 preview 7 for you to try now. C# 15 adds union types , closed hierarchies , the first preview of an updated unsafe model, collection expression arguments, extension indexers, and labeled break and continue . For more details on each of these features, see What's new in C# 15 and the articles linked from that page. Union types A union type lets you say, in the type system, exactly which types a value may hold. With object , a marker interface, or an abstract base class, the runtime type can still be anything derived from object or anything that implements or derives from the shared type. A union constrains the value to one of the specified case types . The case types in a union aren't necessarily related by inheritance. Use the closed hierarchies feature to restrict the set of types related by inheritance. public record class Cat(string Name); public record class Dog(string Name); pu...