为什么词典preferred在哈希表? [英] Why is Dictionary preferred over hashtable?

查看:144
本文介绍了为什么词典preferred在哈希表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数编程语言,词典是pferred在哈希表$ P $。 什么是背后的原因是什么?

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

推荐答案

FWIW,一个字典一个哈希表。

FWIW, a Dictionary is a hash table.

如果你的意思是?为什么我们使用Hashtable类的字典类,而不是,那么这是一个简单的答案:字典是一个泛型类型,哈希表是没有的。这意味着你得到的类型安全与字典,因为你不能插入任何随机对象到它,你没有投你拿出的值。

If you meant "why do we use the Dictionary class instead of the Hashtable class?", then it's an easy answer: Dictionary is a generic type, Hashtable is not. That means you get type safety with Dictionary, because you can't insert any random object into it, and you don't have to cast the values you take out.

这篇关于为什么词典preferred在哈希表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆