KeyValuePairpair = new KeyValuePair (1, "one");
int key = pair.Key; string value = pair.Value;
DictionaryExample Brief: An example use case of KeyValuePair could be in building a dictionary of words and their respective definitions. Each word and its definition would be a key-value pair, respectively. The KeyValuePaiir class would be used to store each word and its definition as a single object to be included in the dictionary. Package library: System.Collections.Genericdict = new Dictionary (); dict.Add(1, "one"); dict.Add(2, "two"); dict.Add(3, "three"); foreach (KeyValuePair pair in dict) { Console.WriteLine(pair.Key + " : " + pair.Value); }