When to use a HashTable

后端 未结 8 942
眼角桃花
眼角桃花 2020-12-24 02:13

In C#, I find myself using a List, IList or IEnumerable 99% of the time. Is there a case when it would be b

8条回答
  •  误落风尘
    2020-12-24 02:59

    I use Hashtables quite often to send back key/value collections to Javascript via page methods.

    Dictionaries are good for caching things when you need to retrieve an object given its ID but don't want to have to hit the database: Assuming your collection is not large enough to induce a large number of collisions and your data needs retrieving often enough for an IEnumerable to be too slow, Dictionaries can give a decent speed-up.

提交回复
热议问题