Struct Option<T>
Represents a value type that can be absent
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
Type Parameters
Constructors
Option(T)
Initializes a new instance of the Option<T> structure.
If T is reference type and is null then
object without data is created (HasValue will be false).
Declaration
[Construction(new string[]{"Value"})]
public Option(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Properties
HasNoValue
Gets a value indicating whether the current Option<T> object
has no valid value of its underlying type.
Declaration
public readonly bool HasNoValue { get; }
Property Value
HasValue
Gets a value indicating whether the current Option<T> object
has a valid value of its underlying type.
Declaration
public readonly bool HasValue { get; }
Property Value
Value
Gets the value of the current Option<T> object
if it has been assigned a valid underlying value.
Declaration
public readonly T Value { get; }
Property Value
Type |
Description |
T |
The value of the current Option<T> object if the HasValue
property is true. An exception is thrown otherwise.
|
Methods
Empty()
Creates a news Option<T> object which holds no value.
Declaration
[Construction(UseWhen = "HasNoValue")]
public static Option<T> Empty()
Returns
Equals(Object)
Declaration
public override bool Equals(object other)
Parameters
Type |
Name |
Description |
Object |
other |
|
Returns
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
ToString()
Declaration
public override string ToString()
Returns
Overrides
Operators
Equality(Option<T>, Option<T>)
Declaration
public static bool operator ==(Option<T> a, Option<T> b)
Parameters
Returns
Explicit(Option<T> to T)
Defines an explicit conversion of a Option<T> instance to its underlying value.
Declaration
public static explicit operator T(Option<T> value)
Parameters
Type |
Name |
Description |
Option<T> |
value |
|
Returns
Implicit(T to Option<T>)
Creates a new Option<T> object initialized to a specified value.
Declaration
public static implicit operator Option<T>(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
Implicit(Option.NoneType to Option<T>)
Declaration
public static implicit operator Option<T>(Option.NoneType none)
Parameters
Returns
Inequality(Option<T>, Option<T>)
Declaration
public static bool operator !=(Option<T> a, Option<T> b)
Parameters
Returns