c# - Check if a object is the same -


im doing queries active directory, building own dictionary contain name, phone , email per user.

then store user file, this: domain\groupt\group\user;<checksum>

where path before ; unique id user (a user can in different groups have track that) , <checksum> .gethashcode() of dictinary object user.

then have timer every 30 sec checks ad , builds same dictinary user , looks id , checksum file.

but not working. reason .gethashcode() generates new int when there no change name, phone or email... im thinking not function use.

so how check if object has changed in way tried describe above?

you may have override gethashcode method of user object create custom one.

something

public override int gethashcode() {   return string.concat(this.domain,this.name,...).gethashcode(); } 

but, anyway comparing hashcodes ensures objects not equal when result different, if hashcodes same still have check if contents same or not. hashcode useful distributing objects in hastables, not real comparison.

you better implement icomparable interface in classes.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -