I need to use a Dictionary, where TKey is a pair of ints.
I thought of using KeyValuePair for the type of my keys and I was wondering if this was the best way around.
I’m also curious to know if the Dictionary will create separate entries for two different KeyValuePair objects with the same ints and why.
For instance:
var myDictionary = new Dictionary<KeyValuePair<int,int>, string>();
myDictionary.Add(new KeyValuePair<int,int>(3, 3), "FirstItem");
myDictionary.Add(new KeyValuePair<int,int>(3, 3), "SecondItem");
// does the dictionary allow this?
Maybe you should consider using a
TupleAccording to MSDN documentation, a
TupleobjectsEqualsmethod will use the values of the twoTupleobjects. This would result in one entry perTuplein the outer dictionary and allow you to store a listing of the values per key.