DEV Community

Discussion on: Eliminating Nulls in C# with Functional Programming

Collapse
 
seangwright profile image
Sean G. Wright

I use a Result<T> type, mostly as the return for calls to services / data access abstractions.

I then have conditional blocks like if (result.IsFailure) { ... } or if (result.IsSuccess) { ... }.

If it's a success, then the .Value type T property will be populated. If it's a failure then the .Error string property will be populated.

I think Option, Maybe, Result are all valid and the word used depends on your team. Option/Maybe feel a bit more functional and academic. I like them in F# but they feel a bit foreign in C#.