Why is Dictionary preferred over Hashtable in C#?

后端 未结 19 1258
长情又很酷
长情又很酷 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:24

    In most programming languages, dictionaries are preferred over hashtables

    I don't think this is necessarily true, most languages have one or the other, depending on the terminology they prefer.

    In C#, however, the clear reason (for me) is that C# HashTables and other members of the System.Collections namespace are largely obsolete. They were present in c# V1.1. They have been replaced from C# 2.0 by the Generic classes in the System.Collections.Generic namespace.

提交回复
热议问题