Struct Optional<T>
- Namespace
- Dynamic
Data .Kernel
- Assembly
- DynamicData.dll
The equivalent of a nullable type which works on value and reference types.
Type Parameters
T
The underlying value type of the Nullable<T> generic type.
- Implements
-
IEquatable<Optional<T>>
- Extension Methods
Properties
HasValue
Gets a value indicating whether the current Nullable<T> object has a value.
Property Value
- bool
true if the current Nullable<T> object has a value; false if the current Nullable<T> object has no value.
None
Gets the default valueless optional.
Property Value
- Optional<T>
Value
Gets the value of the current Nullable<T> value.
Property Value
- T
The value of the current Nullable<T> object if the Has
Value property is true. An exception is thrown if the HasValue property is false.
Exceptions
- Invalid
Operation Exception The Has
Value property is false.
Methods
Create(T?)
Creates the specified value.
Parameters
value
TThe value.
Returns
- Optional<T>
The optional value.
Equals(Optional<T>)
Parameters
other
Optional<T>
Returns
Equals(object?)
Parameters
obj
object
Returns
FromOptional(in Optional<T>)
Gets the value from the optional value.
Parameters
value
Optional<T>The optional value.
Returns
- T
The value.
GetHashCode()
Returns
ToOptional(T?)
Gets the optional from a value.
Parameters
value
TThe value to get the optional for.
Returns
- Optional<T>
The optional.
ToString()
Returns
Operators
operator ==(in Optional<T>, in Optional<T>)
Parameters
Returns
explicit operator T?(in Optional<T>)
Explicit cast from option to value.
Parameters
value
Optional<T>The value.
Returns
- T
The optional value.
implicit operator Optional<T>(T?)
Implicit cast from the vale to the optional.
Parameters
value
TThe value.
Returns
- Optional<T>
The optional value.