We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2fc213e commit 2849641Copy full SHA for 2849641
src/NHibernate/Util/ArrayHelper.cs
@@ -244,5 +244,23 @@ public static bool ArrayEquals(byte[] a, byte[] b)
244
}
245
return true;
246
247
+
248
+ /// <summary>
249
+ /// Calculate a hash code based on the length and contents of the array.
250
+ /// The algorithm is such that if ArrayHelper.ArrayEquals(a,b) returns true,
251
+ /// then ArrayGetHashCode(a) == ArrayGetHashCode(b).
252
+ /// </summary>
253
+ /// <typeparam name="T"></typeparam>
254
+ /// <param name="array"></param>
255
+ /// <returns></returns>
256
+ public static int ArrayGetHashCode<T>(T[] array)
257
+ {
258
+ int hc = array.Length;
259
260
+ foreach (var e in array)
261
+ hc = unchecked(hc*31 + e.GetHashCode());
262
263
+ return hc;
264
+ }
265
266
0 commit comments