Missing
Culture
argument to when case-converting string
92 Console.WriteLine("String is empty!");
93 }
94
95 var myCmp = s1.ToLower() == s2.ToLower(); 96
97 object o = new Foo();
98 var foo = o as Foo;
Missing
Culture
argument to when case-converting string
92 Console.WriteLine("String is empty!");
93 }
94
95 var myCmp = s1.ToLower() == s2.ToLower(); 96
97 object o = new Foo();
98 var foo = o as Foo;
Description
The CultureInfo
class contains information about a specific culture, i.e. the locale. This information is potentially used during sorting, formatting datetime, comparisons, and other related operations. Although methods like ToLower
and ToUpper
do not mandate that you provide this information, it is recommended that you do so, to avoid pitfalls.
Bad Practice
var lowerCase = str.ToLower();
Recommended
var lowerCase = str.ToLower(new CultureInfo("en-US", false));