Difference between Hashtable and dictionary #Csharp #techinterviews #interviewpreparation #interview

preview_player
Показать описание
Difference between Hashtable and Dictionary in c# #hashtable #dictionary #csharp #csharpinterviewquestions

Difference 1: Generics

Dictionary is a generic collection, which means that it can only store elements of a specific type,
whereas HashTable can store elements of any type.

Difference 2: Type Conversion

In a HashTable, the key and value types are both objects, so when you access a value by its key, you need to cast it to the appropriate type before you can use it.
In a Dictionary, the key and value types are strongly typed, so you don't need to cast the value when you access it.

Difference 3: Null Values

A Dictionary can accept null as a valid key or value, whereas a HashTable cannot store null as a key or a value.
Рекомендации по теме
Комментарии
Автор

Quick, concise and very helpful tips. Thanks!!

MrVook