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
The definition of string.IndexOf(string value, StringComparison comparisonType) is such that it returns the minimum integer index for which the following expression is true:
Similarly, the definition of string.LastIndexOf(string value, StringComparison comparisonType) is such that it returns the maximum integer index for which the following expression is true:
(If there is no value index which makes this expression true, IndexOf and LastIndexOf return -1.)
Given this definition, the result of someInputString.LastIndexOf("", StringComparison.Ordinal) should be someInputString.Length for all possible input strings. This is because calling someInputString.Substring(someInputString.Length) will result in the empty string, and any string (including the empty string) trivially starts with itself. Furthermore, there is no larger value index which can be passed into the Substring routine, as any such value would result in an exception.
The text was updated successfully, but these errors were encountered:
(Related to https://github.com/dotnet/coreclr/issues/26608.)
The definition of
string.IndexOf(string value, StringComparison comparisonType)
is such that it returns the minimum integer index for which the following expression is true:Similarly, the definition of
string.LastIndexOf(string value, StringComparison comparisonType)
is such that it returns the maximum integer index for which the following expression is true:(If there is no value index which makes this expression true,
IndexOf
andLastIndexOf
return -1.)Given this definition, the result of
someInputString.LastIndexOf("", StringComparison.Ordinal)
should besomeInputString.Length
for all possible input strings. This is because callingsomeInputString.Substring(someInputString.Length)
will result in the empty string, and any string (including the empty string) trivially starts with itself. Furthermore, there is no larger value index which can be passed into theSubstring
routine, as any such value would result in an exception.The text was updated successfully, but these errors were encountered: