Skip to content
0:00 / 0:00

#oneof#discriminatedunions#csharp

How to use Discriminated Unions Today in C#

Nick Chapsas

429K subscribers • 62 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • Presented by Nick Chapsas
  • Linked in the descriptionmcintyre321/OneOf

Intermediate. Assumes working knowledge.

65K views3 years ago3 recommendations

Programming languagesSoftware designC# and .NETFunctional programmingDesign patterns

Nick Chapsas explains how to use the OneOf library to implement discriminated unions in C# today.

Use code REST15 for 15% off the new From Zero to Hero - REST APIs in .NET course: bit.ly/restchapsas Become a Patreon and get source code access: patreon.com/nickchapsas Hello everybody I'm Nick and in this video I will show you how you can use Discriminated Unions in C# using a Nuget package called OneOf, so you don't have to wait until the feature makes in in C# and be ready to migrate when it does launch. Give OneOf a star on GitHub: github.com/mcintyre321/OneOf Workshops: bit.ly/nickworkshops Don't forget to comment, like and subscribe :) Social Media: Follow me on GitHub: bit.ly/ChapsasGitHub Follow me on Twitter: bit.ly/ChapsasTwitter Connect on LinkedIn: bit.ly/ChapsasLinkedIn Keep coding merch: keepcoding.shop #csharp #dotnet

Why it's here

3 people recommend this

What people say. Recommended for learning how to use discriminated unions in C# to avoid nulls and exceptions.

u/muskyfoxystoatin r/dotnet • Recommends

On “Have you heard of AnyOf .NET Lib?”

Excellent video I happened to watch last week on discriminated unions (which I hadn't heard of before either!) link to this video Basically lets you control the flow of code that has different outcomes without using exceptions. At least that was my interpretation

u/microhivein r/dotnet • Recommends

On “Discussion about nulls”

He is most likely referring to discriminate unions. It is a very powerful tool that makes it easy to avoid the use of nulls and exceptions. Since discriminate unions have yet to be officially supported in C#, you will have to get the third party package OneOf to be able to use it. It is very powerful. See nick chapsis video on it link to this video

u/whoami38902in r/dotnet • Recommends

On “Check out my result type implementation.”

…e to access the data in a non-generic way. But that's usually when I'm doing something stupid with reflection that I shouldn't be doing, so don't do that. If you want to take it further, try using OneOf, and maybe some day the c# team will finally introduce proper discriminated unions. Here's a great video from everyone's favourite, Nick Chapsas [video…

u/SohilAhmed07in r/dotnet • Mentions

On “Have you heard of AnyOf .NET Lib?”

link to this video Here you go