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.​Collections.​Comparer
Assembly: System.Runtime
Inheritance: object → Comparer
Compares two objects for equivalence, where string comparisons are case-sensitive.
Fields and Constants
public static readonly
Comparer
Default
Represents an instance of <see cref="T:System.Collections.Comparer" /> that is associated with the <see cref="P:System.Threading.Thread.CurrentCulture" /> of the current thread. This field is read-only.
public static readonly
Comparer
DefaultInvariant
Represents an instance of <see cref="T:System.Collections.Comparer" /> that is associated with <see cref="P:System.Globalization.CultureInfo.InvariantCulture" /> . This field is read-only.
Methods
public
int
Compare​(object a,
object b)
a
The first object to compare.
b
The second object to compare.
Returns A signed integer that indicates the relative values of <paramref name="a" /> and <paramref name="b" /> , 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="a" /> is less than <paramref name="b" />.</description>
</item>
<item>
<term> Zero</term>
<description>
<paramref name="a" /> equals <paramref name="b" />.</description>
</item>
<item>
<term> Greater than zero</term>
<description>
<paramref name="a" /> is greater than <paramref name="b" />.</description>
</item>
</list>
Performs a case-sensitive comparison of two objects of the same type and returns a value indicating whether one is less than, equal to, or greater than the other.
public
void
GetObjectData​(Runtime.Serialization.SerializationInfo info,
Runtime.Serialization.StreamingContext context)
info
The object to populate with data.
context
The context information about the source or destination of the serialization.
Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with the data required for serialization.
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.