G
Guest
Hi
I have question for GetHashCode() function, Is it correct in following code or there is more efficient way to implement GetHashCode() function
class IntArray
public int[] data
public override int GetHashCode()
int hash = 0
for (int i = 0; i < data.Length; i++
hash ^= data
return hash
public override bool Equals(System.Object cs_
if (obj == null || GetType() != cs_.GetType()) return false
IntArray cs = (IntArray) cs_
if (data.Length != cs.data.Length) return false
for (int i = 0; i < data.Length; i++
if (data != cs.data) return false
return true
As documentation says
If two objects of the same type represent the same value, the hash function must return the same constant value for either object.
Is CLI library is viewable or open source? So I can take reference. Can any one point where to get it
Thank you
Avin Patel
I have question for GetHashCode() function, Is it correct in following code or there is more efficient way to implement GetHashCode() function
class IntArray
public int[] data
public override int GetHashCode()
int hash = 0
for (int i = 0; i < data.Length; i++
hash ^= data
return hash
public override bool Equals(System.Object cs_
if (obj == null || GetType() != cs_.GetType()) return false
IntArray cs = (IntArray) cs_
if (data.Length != cs.data.Length) return false
for (int i = 0; i < data.Length; i++
if (data != cs.data) return false
return true
As documentation says
If two objects of the same type represent the same value, the hash function must return the same constant value for either object.
Is CLI library is viewable or open source? So I can take reference. Can any one point where to get it
Thank you
Avin Patel