using System; using System.Collections.Generic; public class Test { static void Main() { int[] ints1 = { 1, 1, 2 }; int hash1 = GetHashCode(ints1); int[] ints2 = { 2 }; int hash2 = GetHashCode(ints2); Console.WriteLine("hash1 == {0}", hash1); Console.WriteLine("hash2 == {0}", hash2); } static int GetHashCode(IEnumerable integers) { int hash = 0; foreach(int integer in integers) { int x = integer; x ^= x >> 17; x *= 830770091; // 0xed5ad4bb x ^= x >> 11; x *= -1404298415; // 0xac4c1b51 x ^= x >> 15; x *= 830770091; // 0x31848bab x ^= x >> 14; hash += x; } return hash; } }