当前位置: 移动技术网 > IT编程>开发语言>c# > dictionary vs Hashtables

dictionary vs Hashtables

2019年09月09日  | 移动技术网IT编程  | 我要评论


dictionary
dictionary is generic type dictionary<tkey,tvalue>
dictionary class is a strong type < tkey,tvalue > hence, you must specify the data types for key and value.
there is no need of boxing/unboxing.
when you try to access non existing key dictionary, it gives runtime error.
dictionary maintains an order of the stored values.
there is no need of boxing/unboxing, so it is faster than hashtable.
hashtable
hashtable is non-generic type.
hashtable is a weakly typed data structure, so you can add keys and values of any object type.
values need to have boxing/unboxing.
when you try to access non existing key hashtable, it gives null values.
hashtable never maintains an order of the stored values.
hashtable needs boxing/unboxing, so it is slower than dictionary.

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网