Table of Contents

Struct Optional<T>

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Core.dll

Represents an optional parameter that might or might not have a value.

public struct Optional<T>

Type Parameters

T

The type of the parameter.

Inherited Members

Constructors

Optional(T)

Initializes a new instance of the Optional<T> struct with a value.

public Optional(T value)

Parameters

value T

The value of the parameter.

Properties

HasValue

Gets a value indicating whether the optional parameter has a value.

public bool HasValue { get; }

Property Value

bool

true if the optional parameter has a value; otherwise, false.

Value

Gets the value of the optional parameter.

public T Value { get; }

Property Value

T

The value of the optional parameter.

Methods

Replaces(T)

Returns a value indicating whether this optional parameter contains a value that is not equal to an existing value.

public bool Replaces(T value)

Parameters

value T

The value.

Returns

bool

True if this optional parameter contains a value that is not equal to an existing value.

WithDefault(T)

Returns either the value of this optional parameter if it has a value, otherwise a default value.

public T WithDefault(T value)

Parameters

value T

The default value.

Returns

T

Either the value of this optional parameter if it has a value, otherwise a default value.

Operators

implicit operator Optional<T>(T)

Performs an implicit conversion from to an Optional<T> with a value.

public static implicit operator Optional<T>(T value)

Parameters

value T

The value.

Returns

Optional<T>

The result of the conversion.