Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​StringComparer

Assembly: System.Runtime

Inheritance: object → StringComparer

Represents a string comparison operation that uses specific case and culture-based or ordinal comparison rules.

Methods

public int
Compare​(object x, object y)
x An object to compare to <paramref name="y" /> .
y An object to compare to <paramref name="x" /> .
Returns A signed integer that indicates the relative values of <paramref name="x" /> and <paramref name="y" /> , as shown in the following table. <list type="table"> <listheader> <term> Value</term> <description> Meaning</description> </listheader> <item> <term> Less than zero</term> <description> <paramref name="x" /> precedes <paramref name="y" /> in the sort order, or <paramref name="x" /> is <see langword="null" /> and <paramref name="y" /> is not <see langword="null" />.</description> </item> <item> <term> Zero</term> <description> <paramref name="x" /> is equal to <paramref name="y" />, or <paramref name="x" /> and <paramref name="y" /> are both <see langword="null" />.</description> </item> <item> <term> Greater than zero</term> <description> <paramref name="x" /> follows <paramref name="y" /> in the sort order, or <paramref name="y" /> is <see langword="null" /> and <paramref name="x" /> is not <see langword="null" />.</description> </item> </list>
When overridden in a derived class, compares two objects and returns an indication of their relative sort order.
public int
Compare​(string x, string y)
x A string to compare to <paramref name="y" /> .
y A string to compare to <paramref name="x" /> .
Returns A signed integer that indicates the relative values of <paramref name="x" /> and <paramref name="y" /> , as shown in the following table. <list type="table"> <listheader> <term> Value</term> <description> Meaning</description> </listheader> <item> <term> Less than zero</term> <description> <paramref name="x" /> precedes <paramref name="y" /> in the sort order, or <paramref name="x" /> is <see langword="null" /> and <paramref name="y" /> is not <see langword="null" />.</description> </item> <item> <term> Zero</term> <description> <paramref name="x" /> is equal to <paramref name="y" />, or <paramref name="x" /> and <paramref name="y" /> are both <see langword="null" />.</description> </item> <item> <term> Greater than zero</term> <description> <paramref name="x" /> follows <paramref name="y" /> in the sort order, or <paramref name="y" /> is <see langword="null" /> and <paramref name="x" /> is not <see langword="null" />.</description> </item> </list>
When overridden in a derived class, compares two strings and returns an indication of their relative sort order.
public bool
Equals​(object x, object y)
x An object to compare to <paramref name="y" /> .
y An object to compare to <paramref name="x" /> .
Returns <see langword="true" /> if <paramref name="x" /> and <paramref name="y" /> refer to the same object, or <paramref name="x" /> and <paramref name="y" /> are both the same type of object and those objects are equal, or both <paramref name="x" /> and <paramref name="y" /> are <see langword="null" /> ; otherwise, <see langword="false" /> .
When overridden in a derived class, indicates whether two objects are equal.
public bool
Equals​(string x, string y)
x A string to compare to <paramref name="y" /> .
y A string to compare to <paramref name="x" /> .
Returns <see langword="true" /> if <paramref name="x" /> and <paramref name="y" /> refer to the same object, or <paramref name="x" /> and <paramref name="y" /> are equal, or <paramref name="x" /> and <paramref name="y" /> are <see langword="null" /> ; otherwise, <see langword="false" /> .
When overridden in a derived class, indicates whether two strings are equal.
public int
GetHashCode​(object obj)
obj An object.
Returns A 32-bit signed hash code calculated from the value of the <paramref name="obj" /> parameter.
When overridden in a derived class, gets the hash code for the specified object.
public int
GetHashCode​(string obj)
obj A string.
Returns A 32-bit signed hash code calculated from the value of the <paramref name="obj" /> parameter.
When overridden in a derived class, gets the hash code for the specified string.
public bool
Equals​(object obj)
Inherited from object
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns A string that represents the current object.
Returns a string that represents the current object.