Hashset, HashTable in c#

HashSet
  • This is an optimized set collection. It helps eliminates duplicate strings or elements in an array.
  • This internally calls the UnionWith method to eliminate the duplications. 
  • It has OverLap, SymmetricExceptWith
    • OverLap - This method returns true or false. It tests to see if any of the HashSet's elements are contained in the IEnumerable argument's elements. Only one equal element is required.

    • SymmetricExceptWith - This method returns only those don't match in the collection.

HashTable -

  • The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection. 
  • hash table is used when you need to access elements by using key, and you can identify a useful key value.
  • This optimizes lookups. It computes a hash of each key you add. It then uses this hash code to look up the element very quickly.
  • It is an older .NET Framework type. It is slower than the generic Dictionary type. But if an old program uses Hashtable, it is helpful to know how to use this type.


Comments

Popular posts from this blog

SQL Interview Questions and Answers

Generic Interface and Factory Pattern in C#

How to get device info IMEI programmatically in xamarin android