C# how to calculate hashcode from an object reference

前端 未结 3 816
[愿得一人]
[愿得一人] 2021-02-18 23:50

Folks, here\'s a thorny problem for you!

A part of the TickZoom system must collect instances of every type of object into a Dictionary<> type.

It is imperati

3条回答
  •  独厮守ぢ
    2021-02-19 00:21

    The hash code doesn't have to be unique. (But uniqueness will improve performance).
    So - one thing you can do is set the hash code by the type name. All object from the same type will have the same hash code.

提交回复
热议问题