Hash table-
1) It can hold any types of items like 1,2,test.
2) It exists in System.Collections namespace.
3) Boxing and un-boxing is needed because it holds the values as Object.
4) Performance degraded due to boxing & nonboxing.
5) If take values of an item which are not exist in Hash table returns null.
6) It is threadsafe and non-generic type.
Dictionary -
1) It is generic type and holds value of same type that are defined in dictionary.
2) It exists in System.Collections.Generic namespace.
3) No Boxing and un-boxing is needed.
4) No Performance degradation count.
5) If take values of an item which are not exist in Dictionary throws exception of KeyNotFound exception.
6) It is not threadsafe.
Or,
1. Hashtable is threadsafe and while Dictionary is not.
2. Dictionary is types means that the values need not to boxing while Hashtable
values need to be boxed or unboxed because it stored the values and keys as objects.
3. When you try to get the value of key which does not exists in the collection, the
dictionary throws an exception of 'KeyNotFoundException' while hashtable returns
null value.
4. When using large collection of key value pairs hashtable would be considered more
efficient than dictionary.
5. When we retrieve the record in collection the hashtable does not maintain the order
of entries while dictionary maintains the order of entries by which entries were added.
6. Dictionary relies on chaining whereas Hashtable relies on rehashing.
1) It can hold any types of items like 1,2,test.
2) It exists in System.Collections namespace.
3) Boxing and un-boxing is needed because it holds the values as Object.
4) Performance degraded due to boxing & nonboxing.
5) If take values of an item which are not exist in Hash table returns null.
6) It is threadsafe and non-generic type.
Dictionary -
1) It is generic type and holds value of same type that are defined in dictionary.
2) It exists in System.Collections.Generic namespace.
3) No Boxing and un-boxing is needed.
4) No Performance degradation count.
5) If take values of an item which are not exist in Dictionary throws exception of KeyNotFound exception.
6) It is not threadsafe.
Or,
1. Hashtable is threadsafe and while Dictionary is not.
2. Dictionary is types means that the values need not to boxing while Hashtable
values need to be boxed or unboxed because it stored the values and keys as objects.
3. When you try to get the value of key which does not exists in the collection, the
dictionary throws an exception of 'KeyNotFoundException' while hashtable returns
null value.
4. When using large collection of key value pairs hashtable would be considered more
efficient than dictionary.
5. When we retrieve the record in collection the hashtable does not maintain the order
of entries while dictionary maintains the order of entries by which entries were added.
6. Dictionary relies on chaining whereas Hashtable relies on rehashing.
No comments:
Post a Comment