DEV Community

Discussion on: OneOf<Us> Discriminated Unions in C#

Collapse
 
mdfrenchman profile image
Mike French

I’ve used dynamic as the return type or a base type. With sub classes, ex: GuestUser, Admin etc inherit from User.
Then checking for result as Admin or something other way to conditionally action by type.

Worked very well in my implementation but I also controlled knowing WHAT the method could potentially return.

Collapse
 
integerman profile image
Matt Eland

That's an interesting idea. You're sort of undercutting the framework and it could be a minor performance impact, but the code is likely better. Any samples you can share?