-
Notifications
You must be signed in to change notification settings - Fork 11
FL0002
David Mitchell edited this page Dec 28, 2018
·
5 revisions
Many methods that operate on strings default to using the current culture, which is not always correct. If a method has an overload that takes a StringComparison parameter, that overload should be invoked with an explicit StringComparison specified.
if (text.StartsWith("http:")) // BAD if (text.StartsWith("http:", StringComparison.Ordinal)) // GOOD
Add a StringComparison.Ordinal argument.
The suggested fix always uses Ordinal comparison; in some cases, culture-sensitive comparision would be better. The fix simply appends the StringComparsion argument to the current argument list, instead of finding the "best" overload to call and mapping the current arguments to it.