Class ObjectExtensions
- Namespace
- Existential
- Assembly
- Existential.Net.dll
Provides extension methods for values of any type that can be used to convert the value to a Maybe<T>.
public static class ObjectExtensions
- Inheritance
-
System.ObjectObjectExtensions
- Inherited Members
-
System.Object.Equals(System.Object)System.Object.Equals(System.Object, System.Object)System.Object.GetHashCode()System.Object.GetType()System.Object.MemberwiseClone()System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ToString()
Methods
ToMaybe<T>(T)
A generic extension method for converting a reference type value to a Maybe<T>
where T
is of the same type.
public static Maybe<T> ToMaybe<T>(this T inValue)
Parameters
inValue
TThe value to be converted to a Maybe<T>.
Returns
Type Parameters
T
The type of the value being converted to a Maybe.
ToMaybe<T>(Maybe<T>)
A generic extension method for converting a Maybe<T> to a Maybe<T>. Returns the provided Maybe<T> structure unmodified, in order to prevent it being accidentally double-wrapped as a Maybe<Maybe<T>>.
public static Maybe<T> ToMaybe<T>(this Maybe<T> inValue)
Parameters
Returns
Type Parameters
T
The type of the value being converted to a Maybe.
Remarks
This overload of the ToMaybe method prevents a Maybe<T> from being accidentally double-wrapped as a Maybe<Maybe<T>>.
ToMaybe<T>(Nullable<T>)
A generic extension method for converting a value type value to a Maybe<T>
where T
is of the same type.
public static Maybe<T> ToMaybe<T>(this T? inValue)
where T : struct
Parameters
inValue
System.Nullable<T>The value to be converted to a Maybe<T>.
Returns
Type Parameters
T
The type of the value being converted to a Maybe.