NullableReadOnlySpanPairTFirst, TSecondGetValueOrDefault 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 ReadOnlySpanPair<TFirst, TSecond> GetValueOrDefault(
	ReadOnlySpanPair<TFirst, TSecond> defaultValue = default
)

Parameters

defaultValue  ReadOnlySpanPairTFirst, TSecond  (Optional)
The value to return if this NullableReadOnlySpanPairTFirst, TSecond is empty.

Return Value

ReadOnlySpanPairTFirst, TSecond
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 NullableReadOnlySpanPairTFirst, TSecond structure.

If the value used for defaultValue is expensive to construct, consider using the GetValueOrElse(ReadOnlySpanPairFuncTFirst, TSecond) overload instead.

See Also