CSharp examples for System.Collections.Generic:IEnumerable
Get Hash Code for IEnumerable
// The .NET Foundation licenses this file to you under the MIT license. using System.Runtime.CompilerServices; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Diagnostics.Contracts; public class Main{ // We could probably improve the hashing here public static int ListHashCode<T>(this IEnumerable<T> list) {/*from w w w . j a v a 2s . com*/ var cmp = EqualityComparer<T>.Default; int h = 6551; foreach (T t in list) { h ^= (h << 5) ^ cmp.GetHashCode(t); } return h; } }