Dictionary object in C#

Dictionary object in C# is type of data structure which holds the key value of the data. Data-type of Dictionary object is generic we can use any data-type for the key and value. While searching the value for the given key, it directly points to the given key and gets the value so the retrieval of the data is faster. It is inherited from System.Collections.Generic

Syntax : Dictionary < TKey, TValue >

/* Creating Object for Dictionary class */
Dictionary<int, string> Dictin =  new Dictionary<int, string>();

/* Adding values into Dictionary object */
Dictin.Add(1, "C#");
Dictin.Add(2, "VB");
Dictin.Add(3, "F#");
Dictin.Add(4, "J#");

/*  Retriving the value from the Dictionary object by passing Key
 *  Here i am passing 2 as a key to retrive its value  */
string retiveValue = Dictin[2];