This is pseudo code
sbyte[] array1 = new sbyte[100];
array1.setValues();
sbyte[] array2 = (sbyte[])array1.Clone();
But array1.getHashCode() is not equal with array2.getHashCode();
What should I do to get same hash code for array1 and array2?
P.S: Dictionary isn't useful. Because I wanted to add these arrays to a hashtable. And after each adding I need to check for a possible same content array added before.
P.S2: It seems I should clarify my problem. At first I posted the complete question at Using Hash in C# and when it was solved this question was raised.
That isn't the same array - it is a different array with the same contents.
An array GetHashCode() doesnt hash the contents. That hash is simple a hash of the reference.
You could write a custom IEqualityComparer<sbyte[]> if needed for a dictionary etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With