Class Option<TValue>
- Namespace
- Cratis.Monads
- Assembly
- Cratis.Fundamentals.dll
Represents an optional value.
public class Option<TValue> : OneOfBase<TValue, None>, IOneOf
Type Parameters
TValueThe type of the value.
- Inheritance
-
OneOfBase<TValue, None>Option<TValue>
- Implements
-
IOneOf
- Inherited Members
-
OneOfBase<TValue, None>.TryPickT0(out TValue, out None)OneOfBase<TValue, None>.TryPickT1(out None, out TValue)OneOfBase<TValue, None>.ToString()OneOfBase<TValue, None>.GetHashCode()OneOfBase<TValue, None>.ValueOneOfBase<TValue, None>.IndexOneOfBase<TValue, None>.IsT0OneOfBase<TValue, None>.IsT1OneOfBase<TValue, None>.AsT0OneOfBase<TValue, None>.AsT1
- Extension Methods
Constructors
Option(OneOf<TValue, None>)
public Option(OneOf<TValue, None> _)
Parameters
_OneOf<TValue, None>
Properties
HasValue
Gets whether value is present.
public bool HasValue { get; }
Property Value
Methods
None()
Creates a none Option<TValue>.
public static Option<TValue> None()
Returns
- Option<TValue>
The created Option<TValue>.
TryGetValue(out TValue)
Try to get the value.
public bool TryGetValue(out TValue value)
Parameters
valueTValueThe value.
Returns
- bool
A boolean indicating whether the value is present.
Operators
explicit operator None(Option<TValue>)
public static explicit operator None(Option<TValue> _)
Parameters
_Option<TValue>
Returns
- None
explicit operator TValue(Option<TValue>)
public static explicit operator TValue(Option<TValue> _)
Parameters
_Option<TValue>
Returns
- TValue
implicit operator Option<TValue>(None)
public static implicit operator Option<TValue>(None _)
Parameters
_None
Returns
- Option<TValue>
implicit operator Option<TValue>(TValue)
public static implicit operator Option<TValue>(TValue _)
Parameters
_TValue
Returns
- Option<TValue>