.NET Framework Class Library  

CaseInsensitiveComparer Class

Compares two objects for equivalence, ignoring the case of strings.

For a list of all members of this type, see CaseInsensitiveComparer Members.

System.Object
   System.Collections.CaseInsensitiveComparer

[Visual Basic]
<Serializable>
Public Class CaseInsensitiveComparer
   Implements IComparer
[C#]
[Serializable]
public class CaseInsensitiveComparer : IComparer
[C++]
[Serializable]
public __gc class CaseInsensitiveComparer : public IComparer
[JScript]
public
   Serializable
class CaseInsensitiveComparer implements IComparer

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Remarks

CaseInsensitiveComparer implements the IComparer interface supporting case-insensitive comparisons on strings, just as CaseInsensitiveHashCodeProvider implements the IHashCodeProvider interface supporting case-insensitive comparisons on strings.

The Comparer class is the default implementation of the IComparer interface and performs case-sensitive string comparisons.

The objects used as keys by a Hashtable are required to implement or inherit the Object.GetHashCode method (or the IHashCodeProvider interface) and the Object.Equals method (or the IComparer interface). The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the Hashtable might behave incorrectly. For example, when creating a Hashtable, you must use this class with the CaseInsensitiveHashCodeProvider class or any case-insensitive IHashCodeProvider implementation.

String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the System.Globalization namespace and Developing World-Ready Applications.

Requirements

Namespace: System.Collections

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET

Assembly: Mscorlib (in Mscorlib.dll)

See Also

CaseInsensitiveComparer Members | System.Collections Namespace | IComparer | IComparable | Comparer | System.Globalization.CompareInfo | Thread.CurrentCulture | System.Globalization.CultureInfo | CaseInsensitiveHashCodeProvider | Performing Culture-Insensitive String Operations in Collections