CA1307: Specify StringComparison
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2019. Download it here
A string comparison operation uses a method overload that does not set a StringComparison parameter.
Whenever an overload exists that takes a StringComparison parameter, it should be used instead of an overload that does not take this parameter. By explicitly setting this parameter, your code is often made clearer and easier to maintain.
How to Fix Violations
To fix a violation of this rule, change string comparison methods to overloads that accept the StringComparison enumeration as a parameter. For example: change
String.Compare(str1, str2) to
String.Compare(str1, str2, StringComparison.Ordinal).
When to Suppress Warnings
It is safe to suppress a warning from this rule when the library or application is intended for a limited local audience and will therefore not be localized.