Struct Option<T>
A wrapper that may or may not contain a value of type T
.
public readonly record struct Option<T> : IEquatable<Option<T>>
Type Parameters
T
Value type.
- Implements
-
IEquatable<Option<T>>
- Inherited Members
Properties
HasValue
Gets a value indicating whether the value is present.
public bool HasValue { get; }
Property Value
Value
Gets the value.
public T Value { get; }
Property Value
- T
Methods
Deconstruct(out T, out bool)
Deconstructs this instance.
public void Deconstruct(out T value, out bool hasValue)
Parameters
value
TValue.
hasValue
boolWhether the value is present.
Select<TRes>(Func<T, TRes>)
Maps this instance to another type.
public Option<TRes> Select<TRes>(Func<T, TRes> selector)
Parameters
selector
Func<T, TRes>Selector.
Returns
- Option<TRes>
Resulting option.
Type Parameters
TRes
Result type.