c# - Are Hash Codes for structs consistent in the .NET Framework? -


this question has answer here:

do structs built .net framework return same hash code if contents equal? thinking system.drawing.color , size

yes.

correctly implemented gethashcode returns same value items considered equal. existing struct in .net indeed implement such functionality meet expectation.

notes

  • if hash codes equal not mean objects equal.
  • there no requirement hash code same "value" stay same outside single execution of application. unlikely simple types int32 , size, 1 should not rely on hash code. if need consistent value - implement , use own methods.

you can more detailed discussion eric lippert's guidelines , rules gethashcode.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -