Specify a culture or use an invariant version
Specify a culture or use an invariant version
Microsoft docsDescription
Specify a culture or use an invariant culture to avoid implicit dependency on the current culture when calling ToUpper or ToLower. Using an invariant culture yields consistent results regardless of the culture of an application.
Cause
A call is made to System.String.ToUpper or System.String.ToLower without specifying a culture.
How to fix violations
Instead of calling the parameterless System.String.ToUpper or System.String.ToLower methods, call System.String.ToUpper(System.Globalization.CultureInfo) or System.String.ToUpperInvariant, or System.String.ToLower(System.Globalization.CultureInfo) or System.String.ToLowerInvariant.
Example
string s = "hello";
s = s.ToLower();
string s = "hello";
s = s.ToLowerInvariant();When to suppress
It's safe to suppress a warning from this rule if you're certain that System.Threading.Thread.CurrentCulture will never change.