Synopsis: | Do not use ToUpper() or ToLower() for case insensitive string comparison |
Description: |
Do not write code like: if (x.ToLower() == y.ToLower()) { } // Compare two strings case insensitive or Hashtable x = new Hashtable(); if (x.ContainsKey(y.ToUpper()) { } // Compare Hasttable key case insensive. Using if (String.Compare(x, y, true) == 0) { } or Hashtable x = new Hashtable(CaseInsensitiveCompare.DefaultInvariant); // Use case insensive IEqualityComparer if (x.ContainsKey(y)) { } Note: for .NET 1.1 and older use |