RELEASE·Nov 13, 2026, 9:17 PM ET·Emerging signal

Developers can combine record types in C# 15 union declarations

TL;DR:

  • The C# 15 example declares a union named ProductLookup.
  • The ProductLookup declaration combines the Product and ProductNotFound record types.
  • The example uses a switch expression to produce a message for either result type.

Summary

The .NET 11 announcement shows a C# 15 union declaration through a product lookup example. A result can hold either a Product or a ProductNotFound record, and a switch expression handles those alternatives. That makes the example relevant to how developers represent multiple possible outcomes in application code. It demonstrates a language pattern, but doesn't establish broader compatibility or migration requirements.

Open devblogs.microsoft.com in a new tab ↗
Powered by Moatly Lens

The Bigger Picture

The headline tells you what happened. Discover the facts behind it, the forces at work, the connections that matter, and what comes next.

Why This Matters

Microsoft is showing off a cleaner way to write code in the upcoming .NET 11. A new C# 15 feature called union declarations lets developers group different results, like a 'found' item and a 'not found' error, into a single type.

What We Actually Know

  • The example provided by Microsoft uses a union named ProductLookup.
  • The feature allows a single variable to hold either a Product or a ProductNotFound record.

How the Pieces Connect

  • InferenceThis pattern is common in functional programming and helps prevent common errors when handling multiple possible outcomes.

What This Could Change

  • ScenarioIf widely adopted, this could significantly reduce the amount of 'boilerplate' code developers write for error handling.

Where the Story Goes Next

  • Will C# 15 unions support more than two types in a single declaration?
  • Watch for the final .NET 11 release date to see when these features become available for production use.