C# 15 Adds Union Types and Closed Hierarchies

Microsoft's C# 15 ships with .NET 11, bringing union types and exhaustiveness checking to the language.

Updated on Dec. 3, 2026 in Software by Wisevoter Tech Desk

Bold flat-color vector editorial illustration of distinct solid-colored modular blocks fitted into a black tray, with one empty compartment, representing exhaustive case coverage.
Microsoft released C# 15 on November 10 as part of .NET 11, adding union types and compiler checks that flag switch expressions missing declared cases. AI Illustration. Upload story photo >

Microsoft introduced union types and closed type hierarchies in C# 15, released as part of .NET 11 on November 10. The compiler now checks whether a switch expression accounts for all declared alternatives.

Why it matters

Exhaustiveness checking helps developers catch missing cases before deployment rather than at runtime. The change gives C# a construct similar to those found in Rust's enums and Kotlin's sealed classes.

C# 15 is the default language version for .NET 11 projects, which receive Standard Term Support for 2 years. The extraction does not include adoption figures or measured compiler overhead for the new exhaustiveness checks.

The players

Microsoft

Microsoft is a US technology company that develops the C# language and the .NET platform.

The details

Developers can use a union type to state the possible results directly, instead of returning a broadly typed object or building an artificial inheritance relationship. The compiler verifies that a switch expression covers the declared alternatives. .NET 11 also includes a native ahead-of-time compiled command-line host, a persistent MSBuild server, asynchronous validation in ASP.NET Core, OpenAPI 3.2 support, and built-in Zstandard compression.

Timeline

  1. November 10, 2026: .NET 11 released with C# 15 as its default language version.

  2. December 3, 2026: Article published explaining union types in C# 15.

The Tech Race

C# 15's closed type hierarchies bring the sealed-type approach of Kotlin's sealed classes and Rust's enums into the .NET ecosystem. The move narrows the gap between C# and languages that already enforce exhaustive pattern matching.

Developers targeting .NET 11 will get C# 15 by default, so switch expressions will be checked for missing cases at compile time. Teams upgrading projects can start replacing broad return types with union types where the set of possible results is fixed.

The takeaway

Using exhaustiveness checking in switch expressions lets developers catch unhandled cases during compilation. Teams can review existing switch logic to see where closed alternatives would make the code clearer.

Further reading

Explore more software news for context on developer tooling and language releases.

Source note: This article includes information reported by ADTmag.