String comparison - strA.ToLower()==strB.ToLower() or strA.Equals(strB,StringComparisonType)?
问题 As per title, what practise for string comparisons do you use and why? 回答1: You haven't specified a platform, but I'm guessing .NET. I would strongly suggest you use the latter form - because case comparisons aren't as simple as you might expect. (It also avoids creating extra strings, but that's a different matter.) For example, what do you want your code to do when presented with "mail" and "MAIL" when it's running in Turkey? If you use ToLower it will return false, and likewise if you use