Type Summary

						public interface IHashCodeProvider
{
  // Methods
     int GetHashCode (object obj);
}

BG Note that the IHashCodeProvider interface allows you to define your own hash function for a given object. This allows users to either override it for special comparisons such as case-insensitive string lookup, or to replace a poorly written hash function on a third party data type. Combined with IComparer, you can use types as keys in a Hashtable even if the original author neglected to override Equals and GetHashCode on their type.

One note on IHashCodeProvider—many of our users either don't get the type or don't understand when they need to do it. We've found instances where people want to use a case-insensitive Hashtable, yet they remember to ...

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.