Video summary
Union Types are Finally in .NET, but who cares?
Main summary
Key takeaways
Summary
Nick Chapsas demonstrates the new union types feature in C# 15/.NET 11. A union restricts a value to one of a specified set of types. For example, a payment method could be either a card payment or a bank transfer.
The main benefit is exhaustive handling. When switching over a union, the compiler can warn if a case is missing. Since a union can contain only its declared alternatives, code doesn’t need a catch-all branch for unknown types. This can make result types—such as user creation outcomes like “created,” “email exists,” or “invalid email”—safer and easier to handle.
Chapsas describes the feature as a simplified form of what developers might expect from discriminated unions. He shows that the compiler lowers a union to a simple struct that stores the active value, characterizing the feature as syntactic sugar rather than magic.
He also argues that developers should continue to care about language features even when AI agents generate code. Agents may not know about newer features if their training data is outdated. His suggested solution is to give agents a skill that documents C# 15 features and explains when to use them, so they can generate or modernize code appropriately.
Demo and Guidance
- Union type syntax: Define a union from a fixed set of alternatives, such as
CardPaymentorBankTransfer. - Exhaustive switching: Handle every declared alternative. The compiler warns when a case is omitted; Chapsas recommends treating this warning as an error.
- Compiler implementation: The union is lowered to a struct that stores the active value.
- AI-agent guidance: Create or install a skill that documents new language features and tells agents when to use them.
Main Speaker and Source
- Nick Chapsas — presenter and source of the feature demonstration and analysis.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.