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.
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论