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
Related to dotnet/runtime#43736.
(Edit: this isn't a dupe, but the issue has the same explanation. I've summarized it below.)
In a nutshell, the overload of string.IndexOf that's being called is performing a culture-sensitive check, when an ordinal check is intended.
There are two suggested workarounds:
If you're searching for a single char (e.g., '\n'), change the code from strText.IndexOf("\n") to strText.IndexOf('\n') instead. Searching for single chars will be ordinal.
If you're searching for a literal substring, change the code from strText.IndexOf("text") to strText.IndexOf("text", StringComparison.Ordinal) instead.
The code analyzer rules CA1307 and CA1309 can assist with this. See dotnet/docs#21249, section "Option 1: Enable code analyzers to help detect possibly-buggy call sites" for more information.
The text was updated successfully, but these errors were encountered: