-
Notifications
You must be signed in to change notification settings - Fork 15
GeneralTypesExtensions
public static T? AsNullable<T>(this Option<T> option) where T : struct
Converts an Option<T>
to T?
.
If option
contains a value, then that value is returned. Otherwise null
is returned. Note, this method is for structs only.
public static T? AsNullableRef<T>(this Option<T> option) where T : class
Converts an Option<T>
to T?
.
If option
contains a value, then that value is returned. Otherwise null
is returned. Note, this method is for classes only and only really makes sense when used with C# 8's nullable reference types feature.
public static Option<T> ToOption<T>(this T obj)
Performs a null-checked conversion of obj
to an Option<T>
.
If obj
is null
, then an Option<T>
containing none
is returned. Otherwise, an Option<T>
containing obj
is returned. This method supports both nullable structs and classes (nullable reference types in C# 8).
public static Option<T> TryCast<T>(this object value) where T : class
Attempts to cast value
to T
and converts the result to an Option<T>
, using ToOption
(above).
If value
is of type T
, and is not null
, then an Option<T>
containing value
is returned. Otherwise an Option<T>
containing none
is returned.
Action
/Func
conversionsCycle
methods- Converting between
Action
andFunc
- Extension methods for existing types that use
Option<T>
- Indexed enumerations
IEnumerable<T>
cons- Option-based parsers
- Partial function applications
- Pattern matching
- Pipe Operators
- Typed lambdas
Any
Either<TLeft,TRight>
None
Option<T>
Success<T>
Union<T1,T2>
Union<T1,T2,T3>
Union<T1,T2,T3,T4>
Unit
ValueOrError