MemoryExtensions.SplitOnce<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) Method

Splits a ReadOnlySpan<T> into two parts at the first occurrence of a separator.

Definition

Namespace: Ookii.Common
Assembly: Ookii.Common (in Ookii.Common.dll) Version: 1.0.0+7c2900b8a16cd8ae46bdd79d8f105034712c5fa3
C#
public static NullableReadOnlySpanPair<T, T> SplitOnce<T>(
	this ReadOnlySpan<T> span,
	ReadOnlySpan<T> separator
)
where T : Object, IEquatable<T>

Parameters

span  ReadOnlySpan<T>
The ReadOnlySpan<T> to split.
separator  ReadOnlySpan<T>
The separator to split the span at.

Type Parameters

T
The type of the items in the ReadOnlySpan<T>.

Return Value

NullableReadOnlySpanPair<T, T>
If the separator was found, a NullableReadOnlySpanPair<TFirst, TSecond> containing the parts before and after the separator; otherwise, an empty NullableReadOnlySpanPair<TFirst, TSecond>.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ReadOnlySpan<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also