MemoryExtensions.SplitOnce(ReadOnlyMemory<Char>, ReadOnlySpan<Char>, StringComparison) Method

Splits a read-only memory region of characters 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 (ReadOnlyMemory<char> , ReadOnlyMemory<char> )? SplitOnce(
	this ReadOnlyMemory<char> memory,
	ReadOnlySpan<char> separator,
	StringComparison comparisonType
)

Parameters

memory  ReadOnlyMemory<Char>
The memory region to split.
separator  ReadOnlySpan<Char>
A span of characters containing the separator to split on.
comparisonType  StringComparison
The type of string comparison to use to find the separator.

Return Value

Nullable<ValueTuple<ReadOnlyMemory<Char>, ReadOnlyMemory<Char>>>
If the separator was found, a tuple containing the parts before and after the separator; otherwise, null.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ReadOnlyMemory<Char>. 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