Calcolare l’Hash di una lista (Extension Method)
public static class Extensions
{
public static int CalculateHash<T>(this List<T> myList) where T : IEquatable<T>
{
if (myList.Count == 0) return 0;
unchecked
{
return myList.Aggregate(0, (current, v) => (current ^ 397)*v.GetHashCode());
}
}
}
Commenti(0)

