logoalt Hacker News

simonasklast Monday at 8:01 AM1 replyview on HN

I think in C# the way to solve this is to have two separate types, `Ok<TValue>` and `Err<TError>`, and provide implicit conversions for both to `Result<TValue, TError>`.

The static method approach showcased in the article is really long-winded.


Replies

oaieylast Monday at 8:13 AM

Yes. Or even simpler, static imported functions. That is similar to how ASP.NET Core handles HTTP feedback. A very common and understood concept.

With implicit type parameters this boils down to Ok(4) or BadRequest()