Open silkfire opened 1 day ago
Tagging subscribers to this area: @dotnet/area-system-memory See info in area-owners.md if you want to be subscribed.
What sort of use cases do you have for EndsWithAny
(note that we also didn't expose a LastIndexOfAny
for SearchValues<string>
)?
Good question; I actually wasn't aware of that. I assume StartsWithAny
would be more common (and therefore more useful) than EndsWithAny
so including the latter one would only be to make the API complete.
Background and motivation
There currently doesn't seem to be a means of checking whether the beginning or the end of a string equals to any of the values contained in a specified set of values in an optimized way using
SearchValues<string>
that was introduced in .NET 9. There are other specialized extension APIs involvingReadOnlySpan<char>
andSearchValues<string>
that were recently added (e.g.IndexOfAny<T>(ReadOnlySpan<char>, SearchValues<string>)
,ContainsAny(ReadOnlySpan<char>, SearchValues<string>)
et al.) but this particular API seems to be missing.One use case could be if you need to efficiently check whether a string starts with any one of a particular set of prefixes in order to determine whether your application code supports or handles that particular item.
See also #94155.
API Proposal
API Usage
Alternative Designs
N/A
Risks
N/A