Class Option<TValue>

Namespace
Cratis.Monads
Assembly
Cratis.Fundamentals.dll

Represents an optional value.

public class Option<TValue> : OneOfBase<TValue, None>, IOneOf

Type Parameters

TValue

The 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>.Value
OneOfBase<TValue, None>.Index
OneOfBase<TValue, None>.IsT0
OneOfBase<TValue, None>.IsT1
OneOfBase<TValue, None>.AsT0
OneOfBase<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

bool

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

value TValue

The 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>