Why is Dictionary preferred over Hashtable in C#?

后端 未结 19 1455
长情又很酷
长情又很酷 2020-11-22 05:53

In most programming languages, dictionaries are preferred over hashtables. What are the reasons behind that?

19条回答
  •  误落风尘
    2020-11-22 06:31

    People are saying that a Dictionary is the same as a hash table.

    This is not necessarily true. A hash table is one way to implement a dictionary. A typical one at that, and it may be the default one in .NET in the Dictionary class, but it's not by definition the only one.

    You could equally well implement a dictionary using a linked list or a search tree, it just wouldn't be as efficient (for some metric of efficient).

提交回复
热议问题