Hashcodes
-
Does anybody know a good hashcode algorithm to generate unique codes? What if you have two objects and their properties are equal? How would a hashcode be unique then? Here, I am making an assumption that the hashcode is created using the properties of the control. So I guess the real question is: Is there a way to generate a unique hashcode that doesn't rely on the properties of the object? Thanks Eric
-
Does anybody know a good hashcode algorithm to generate unique codes? What if you have two objects and their properties are equal? How would a hashcode be unique then? Here, I am making an assumption that the hashcode is created using the properties of the control. So I guess the real question is: Is there a way to generate a unique hashcode that doesn't rely on the properties of the object? Thanks Eric
-
Does anybody know a good hashcode algorithm to generate unique codes? What if you have two objects and their properties are equal? How would a hashcode be unique then? Here, I am making an assumption that the hashcode is created using the properties of the control. So I guess the real question is: Is there a way to generate a unique hashcode that doesn't rely on the properties of the object? Thanks Eric
Does the hashcode need to be unique/same across sessions? What're you using it for: uniqueness testing or sorting? If you don't need cross session consistancy or can save the code somehow, and are only using it for uniqueness testing: just give each object a guid.
-
Does anybody know a good hashcode algorithm to generate unique codes? What if you have two objects and their properties are equal? How would a hashcode be unique then? Here, I am making an assumption that the hashcode is created using the properties of the control. So I guess the real question is: Is there a way to generate a unique hashcode that doesn't rely on the properties of the object? Thanks Eric
-
Does anybody know a good hashcode algorithm to generate unique codes? What if you have two objects and their properties are equal? How would a hashcode be unique then? Here, I am making an assumption that the hashcode is created using the properties of the control. So I guess the real question is: Is there a way to generate a unique hashcode that doesn't rely on the properties of the object? Thanks Eric
Be aware that if comparison of instances return
true
, like in:obj1.Equal(obj2) == true
then they must return the same hashcode.
obj1.Hahscode() == obj2.hashcode()
So, if you implement your own hashcode that is unique for every instance, make sure to override the Equal method to always return
false
. If you don't do that, your class won't be usable in Arrays and Hashtables. -------- "I say no to drugs, but they don't listen." - Marilyn Manson -
Does anybody know a good hashcode algorithm to generate unique codes? What if you have two objects and their properties are equal? How would a hashcode be unique then? Here, I am making an assumption that the hashcode is created using the properties of the control. So I guess the real question is: Is there a way to generate a unique hashcode that doesn't rely on the properties of the object? Thanks Eric