Represents a string comparison operation that uses specific case and culture-based or ordinal comparison rules.
Assembly: mscorlib (in mscorlib.dll)
Thetype exposes the following members.
|CurrentCulture||Gets a object that performs a case-sensitive string comparison using the word comparison rules of the current culture.|
|CurrentCultureIgnoreCase||Gets a object that performs case-insensitive string comparisons using the word comparison rules of the current culture.|
|InvariantCulture||Gets a object that performs a case-sensitive string comparison using the word comparison rules of the invariant culture.|
|InvariantCultureIgnoreCase||Gets a object that performs a case-insensitive string comparison using the word comparison rules of the invariant culture.|
|Ordinal||Gets a object that performs a case-sensitive ordinal string comparison.|
|OrdinalIgnoreCase||Gets a object that performs a case-insensitive ordinal string comparison.|
|Compare(Object, Object)||When overridden in a derived class, compares two objects and returns an indication of their relative sort order.|
|Compare(String, String)||When overridden in a derived class, compares two strings and returns an indication of their relative sort order.|
|Create||Creates a object that compares strings according to the rules of a specified culture.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Equals(Object, Object)||When overridden in a derived class, indicates whether two objects are equal.|
|Equals(String, String)||When overridden in a derived class, indicates whether two strings are equal.|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode()||Serves as the default hash function. (Inherited from Object.)|
|GetHashCode(Object)||When overridden in a derived class, gets the hash code for the specified object.|
|GetHashCode(String)||When overridden in a derived class, gets the hash code for the specified string.|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
|IComparer.Compare||Compares two objects and returns a value that indicates whether one is less than, equal to, or greater than the other.|
|IEqualityComparer.Equals||Determines whether the specified objects are equal.|
|IEqualityComparer.GetHashCode||Returns a hash code for the specified object.|
An object derived from the class embodies string-based comparison, equality, and hash code operations that take into account both case and culture-specific comparison rules. You can use the class to create a type-specific comparison to sort the elements in a generic collection. Classes such as Hashtable, Dictionary(TKey, TValue), SortedList, and SortedList(TKey, TValue) use the class for sorting purposes.
A comparison operation that is represented by the class is defined to be either case-sensitive or case-insensitive, and use either word (culture-sensitive) or ordinal (culture-insensitive) comparison rules. For more information about word and ordinal comparison rules, see System.Globalization.CompareOptions.
You might be confused about how to use the class properties because of a seeming contradiction. The class is declared abstract (MustInherit in Visual Basic), which means its members can be invoked only on an object of a class derived from the class. The contradiction is that each property of the class is declared static (Shared in Visual Basic), which means the property can be invoked without first creating a derived class.
You can call a property directly because each property actually returns an instance of an anonymous class that is derived from the class. Consequently, the type of each property value is , which is the base class of the anonymous class, not the type of the anonymous class itself. Each class property returns a object that supports predefined case and comparison rules.
.NET FrameworkSupported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0
.NET Framework Client ProfileSupported in: 4, 3.5 SP1
Portable Class LibrarySupported in: Portable Class Library
.NET for Windows Store appsSupported in: Windows 8
.NET for Windows Phone appsSupported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.