Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (8 sloc) 659 Bytes

MA0001 - Use StringComparison parameter when possible

Not all of the string manipulation methods in .NET use the same rules for string comparison by culture and case. For instance, string.Equals(string, string) uses StringComparison.Ordinal whereas IndexOf(String) uses StringComparison.CurrentCulture. So, you should use an overload that does not use default values.

string.Equals("a", "b");

// Should be
string.Equals("a", "b", StringComparison.Ordinal);

You'll find more details in the documentation: https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings#specifying_string_comparisons_explicitly

You can’t perform that action at this time.