JetBrains Rider 2017.3 Help

Code Inspection: String.StartsWith is culture-specific

Similarly to the Specify a culture in string conversion explicitly, this inspection helps to avoid problems with running your code on machines with different culture settings.

When stings are compared using String.StartsWith, comparison results may differ depending on the machine's locale. The canonical example is the Turkish where there is a lowercase dotless "ı" with the corresponding uppercase "I", and a lowercase "i" with an uppercase "İ" with the dot. As a result, your code may return different results on machines with different culture settings.

To resolve this problem, JetBrains Rider suggests adding the culture-invariant StringComparison.Ordinal explicitly to the method call.

Last modified: 8 March 2018

See Also