Optional<T>.GetValueOrDefault method (1 of 2)

Retrieves the value of the current Optional{T} object, or the object’s default value.

public T GetValueOrDefault()

Return Value

The value of the Value property if the HasValue property is true; otherwise, the default value of the type T.

See Also


Optional<T>.GetValueOrDefault method (2 of 2)

Retrieves the value of the current Optional{T} object, or the specified default value.

public T GetValueOrDefault(T defaultValue)
parameter description
defaultValue A value to return if the HasValue property is false.

Return Value

The value of the Value property if the HasValue property is true; otherwise, the defaultValue parameter.

See Also