Ads Inside Post

Search in This Blog

Dictionary in C#

Dictionary in C#

Dictionary is faster that ArrayList and HashTable in C#, here is the example that how to use Dictionary in C#.

Dictionary<int, string> dict = new Dictionary<int, string>();
//You are free to use either :
//Dictionary<string,int> dict = new Dictionary<string,int>();
dict.Add(1, "AA");
dict.Add(2, "BB");
dict.Add(3, "CC");

foreach (var data in dict) {
      nmCode = data.Key.ToString();
      nm = data.Value.ToString();