<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf" -->

---
title: Explore union types in C# 15 | daily.dev
description: 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...
canonical: https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Explore union types in C# 15 | daily.dev
og:description: 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...
og:url: https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf
og:image: https://api.daily.dev/og/posts/oYgraaUHF.png
og:image:alt: Explore union types in C# 15
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Explore union types in C# 15

**[DevBlogs](https://daily.dev/sources/devblogs)** · 8 min read · 64 upvotes · 3 comments

## Summary

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 struct with implicit conversions from each case type and a `Value` property. Switch expressions over union types are exhaustive without needing a discard arm, and adding a new case type triggers compiler warnings on incomplete switches. Custom union types are also supported via a `[Union]` attribute for existing libraries, including a non-boxing access pattern for performance-sensitive scenarios. Related proposals for closed hierarchies and closed enums round out a comprehensive exhaustiveness story for C#.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://devblogs.microsoft.com/dotnet/csharp-15-union-types>

## Community discussion

Top comments from developers on daily.dev.

**@ilministrodelpo** · 0 upvotes

> Pretty much useless and redundant

---

Tags: [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Explore union types in C# 15","url":"https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf"},"datePublished":"2026-04-02T17:08:25.119Z","dateModified":"2026-04-02T17:08:47.760Z","description":"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...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/445a472eea4d73bb688c8139e6eef8c0?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/445a472eea4d73bb688c8139e6eef8c0?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"DevBlogs","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DevBlogs","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/8f68b453325f482ebeb73fb780092713","url":"https://daily.dev/sources/devblogs"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":64},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":".net,c#","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DevBlogs","item":"https://daily.dev/sources/devblogs"},{"@type":"ListItem","position":3,"name":"Explore union types in C# 15"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/explore-union-types-in-c-15-oygraauhf","comment":[{"@type":"Comment","text":"Pretty much useless and redundant","datePublished":"2026-04-08T06:52:58.312Z","url":"https://daily.dev/posts/oYgraaUHF#c-FmZObYrSU","author":{"@type":"Person","name":"Alessandro Mandelli","url":"https://daily.dev/ilministrodelpo","image":"https://avatars.githubusercontent.com/u/7769348?v=4"}}]}
```

