C# 15 adds union types

antondevtips.com10 min read

The author examines the introduction of union types in C# 15 alongside .NET 11, detailing how they enable exhaustive pattern matching for unrelated types. The article explores language-level mechanics, compiler-generated structures, JSON serialization support, closed hierarchies, and performance trade-offs such as boxing on hot paths. Open article →