StringSegmentLastIndexOf(ReadOnlySpanChar, Int32, Int32, StringComparison) Method

Gets the zero-based index of the last occurrence of the specified value in this StringSegment using the specified startIndex, count and comparison.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public int LastIndexOf(
	ReadOnlySpan<char> value,
	int startIndex,
	int count,
	StringComparison comparison = StringComparison.Ordinal
)

Parameters

value  ReadOnlySpanChar
The ReadOnlySpan<char> to seek.
startIndex  Int32
The search starting position.
count  Int32
The number of character positions to examine.
comparison  StringComparison  (Optional)
A StringComparison value that specified the rules for the search. This parameter is optional.
Default value: Ordinal.

Return Value

Int32
The zero-based index position of value if that ReadOnlySpan<char> is found, or -1 if it is not. If value is ReadOnlySpan<char>.Empty, the return value is the smaller of startIndex and the last index position of this StringSegment.

Remarks

If comparison is Ordinal, then no new string allocation occurs on any platforms.

If comparison is other than Ordinal, then depending on the targeted platform a new string allocation may occur. The .NET Core 3.0 and newer builds do not allocate a new string with any comparison values.

See Also