Name
Comparer
Synopsis
The Comparer
class is used to compare two objects of the same type.
The Compare()
method takes two objects. If the first object is less than the second, a
negative value is returned. If the first object is greater
than the second, a positive value is returned.
If the objects are equal, zero is returned.
The comparisons of strings are case-sensitive. For case insensitive
string comparisons, use CaseInsensitiveComparer
.
public sealed class Comparer : IComparer { // Public Static Fields public static readonly field Comparer Default; // =System.Collections.Comparer // Public Instance Methods public method int Compare(object a, object b); // implements IComparer }
Get C# in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.