Tag: Dictionary

Difference between Hash table and Dictionary in .NET

Here’s a simple difference between Hashtable and Dictionary in .NET Dictionary Hashtable It is generic in nature It is non generic in nature It is defined in the namespace System.Collections.Generic It is defined in the namespace System.Collections When a request is made to the dictionary and if the key does not exists , you get an exception When a request is made to the Hashtable…

How to update the value in a Dictionary in C# ?

Below is a sample code snippet demonstrating how to update the value that is stored within the dictionary using C#. We access the dictionary with the key as index and set the value. How to update the value in a Dictionary in C# ?

How to detect if a key exists in a Dictionary in C# ?

If you want to detect if a key exists in a dictionary in C# , you can use the contains method of the dictionary which return true if the key is found. How to detect if a key exists in a Dictionary in C# ? Below is a sample source code that illustrates how to find out if the exists in a dictionary using the…