Is there a better data structure than Dictionary if the values are objects and a property of those objects are the keys?

前端 未结 4 1795
暖寄归人
暖寄归人 2021-01-18 02:27

I have a Dictionary where the int is a property of obj. Is there a better data structure for this? I feel like u

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 03:15

    There is a KeyedCollection class.

    EDIT: The KeyedCollection can use a dictionary internally, but it cleaner interface for this particular scenario than a raw dictionary since you can lookup by values directly. Admittedly I don't find it very useful in general.

提交回复
热议问题