Its Dictionary
Syntax: Dictionary<TKey, TValue>
var myDictionary = new Dictionary<int, string>();
myDictionary.Add(10, "January");
myDictionary.Add(8, "February");
myDictionary.Add(4, "March");
myDictionary.Add(13, "April");
myDictionary.Add(17, "May");
You can also have a List of KeyValuePairs
var list = new List<KeyValuePair<string, int>>()
{
new KeyValuePair<string, int>("January", 10),
new KeyValuePair<string, int>("February", 8),
new KeyValuePair<string, int>("March", 4),
new KeyValuePair<string, int>("April", 13),
new KeyValuePair<string, int>("May", 17),
};
So what is the difference between List<KeyValuePair<T1, T2>> and Dictionary<T1, T2>?
The answer is the List does not enforce uniqueness of the Key.
Meaning you can do this with a List and KeyValuePair.
//Record with same key
new KeyValuePair<string, int>("May", 17),
new KeyValuePair<string, int>("May", 17),
But you cannot do it with a Dictionary
myDictionary.Add(17, "May");
myDictionary.Add(17, "May"); //ERROR
Mapconstructor in JavaScript? Do you want a list of tuples? (.NET has tuples.)["January", "10"]instead of["January", 10]. Are you producing JSON? Did you try tuples with your JSON serializer (which one)?