MemoryExtensions.StripSuffix<T>(ReadOnlyMemory<T>, ReadOnlySpan<T>) Method

Removes a suffix from a ReadOnlyMemory<T>.

Definition

Namespace: Ookii.Common
Assembly: Ookii.Common (in Ookii.Common.dll) Version: 1.0.0+7c2900b8a16cd8ae46bdd79d8f105034712c5fa3
C#
public static ReadOnlyMemory<T>? StripSuffix<T>(
	this ReadOnlyMemory<T> memory,
	ReadOnlySpan<T> suffix
)
where T : Object, IEquatable<T>

Parameters

memory  ReadOnlyMemory<T>
The ReadOnlyMemory<T> to remove the suffix from.
suffix  ReadOnlySpan<T>
The suffix to move.

Type Parameters

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

Return Value

Nullable<ReadOnlyMemory<T>>
If memory ends with suffix, returns the memory without the suffix; otherwise, returns null.

Usage Note

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