C# 15 introduces the `union` keyword in .NET 11 Preview 2, allowing developers to declare a closed set of case types with compiler-enforced exhaustive pattern matching. Unlike object, marker interfaces, or abstract base classes, union types don't require related types and prevent external extension. The compiler generates a
Table of contents
What are union types? Copy linkCustom unions for existing libraries Copy linkRelated proposals Copy linkTry it yourself Copy linkShare your feedback Copy link3 Comments
Sort: