You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into wanting this a few times over the years - most recently, it was for subtracting two BigInt's (my own custom ones, which done similarly to the normal BigInteger, but slightly differently to the BCL ones) - but this is not the only case I've run into wanting this for (I could try to find other cases if wanted, but might take me a while to actually find the relevant code, as I don't remember off the top of my head where it is or what it was for).
This to me doesn't seem any different to having both IndexOf and LastIndexOf, despite IndexOf being used much more overall.
We could also add the this Span<T> ones for consistency with CommonPrefixLength, but idk if that's necessary with first class span these days, although it probably helps with languages like VB.NET using it.
If #126756 gets approved, then we probably want a public static int CommonSuffixLength(this ReadOnlySpan<char> other, StringComparison comparisonType); also to match it.
I’d like to implement the two approved ReadOnlySpan<T>.CommonSuffixLength overloads, with tests for default and custom comparers and unequal span lengths. I’ll keep the scope to the approved API and its tests. Please let me know if anyone is already working on it. I’ll use GitHub Copilot for assistance and review the resulting changes.
Activity
dotnet-policy-service commentedon May 1, 2026
Tagging subscribers to this area: @dotnet/area-system-memory
See info in area-owners.md if you want to be subscribed.
bartonjs commentedon Sep 8, 2026
Video
A good parallel to CommonPrefixLength, but the longer overload shouldn't have a defaulted comparer.
shubmittal commentedon Sep 8, 2026
I’d like to implement the two approved
ReadOnlySpan<T>.CommonSuffixLengthoverloads, with tests for default and custom comparers and unequal span lengths. I’ll keep the scope to the approved API and its tests. Please let me know if anyone is already working on it. I’ll use GitHub Copilot for assistance and review the resulting changes.