When to use a HashTable

后端 未结 8 920
眼角桃花
眼角桃花 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:47

    Use a hashtable, when you need to be able to (quickly) look up items by key.

    Of course, you can search through an IList or IEnumerable etc for a matching key but that will take O(n) time rather than O(1) for Hashtable or Dictionary.

提交回复
热议问题