Type Summary

						public interface IComparer
{
  // Methods
     int Compare (object x, object y);
}

BG Note that the IComparer interface allows you to define your own ordering over types, when the original author may not have envisioned a need to sort the class. It's a great hook for comparison and sorting. Combined with IHashCodeProvider, you can use types as keys in a Hashtable even if the original class author neglected to override Equals and GetHashCode for their type.

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library 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.