NullableReadOnlySpanTGetValueOrDefault Method

Returns the contained value, or the specified default value if there is no value.

Definition

Namespace: Ookii.Common
Assembly: Ookii.Common (in Ookii.Common.dll) Version: 1.0.0+7c2900b8a16cd8ae46bdd79d8f105034712c5fa3
C#
public ReadOnlySpan<T> GetValueOrDefault(
	ReadOnlySpan<T> defaultValue = default
)

Parameters

defaultValue  ReadOnlySpanT  (Optional)
The value to return if this NullableReadOnlySpanT is empty.

Return Value

ReadOnlySpanT
If the HasValue property is , the Value property; otherwise, defaultValue.

Remarks

This method provides an alternative to using the ?? operator, which does not work with the NullableReadOnlySpanT structure.

If the value used for defaultValue is expensive to construct, consider using the GetValueOrElse(ReadOnlySpanFuncT) method instead.

See Also