← Back
Milan Jovanovic June 26, 2026 2m

Union types are FINALLY coming to C#

Summary

C# is introducing union types to address the long-standing issue of clearly representing methods that can return multiple distinct outcomes, moving beyond workarounds like tuples or the result pattern. This new feature, demonstrated through a "get user or throw" example which now explicitly returns a `UserResult` type, provides compile-time safety by ensuring all possible union members are handled, leading to more robust and transparent code. The practical takeaway is that union types offer an expressive and safe way to model varied return values, improving developer clarity and reducing runtime errors.

View original episode ↗