NullableSpanTGetValueOrDefault 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 Span<T> GetValueOrDefault(
	Span<T> defaultValue = default
)

Parameters

defaultValue  SpanT  (Optional)
The value to return if this NullableSpanT is empty.

Return Value

SpanT
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 NullableSpanT structure.

If the value used for defaultValue is expensive to construct, consider using the GetValueOrDefault(SpanT) overload instead.

See Also