Is there a dictionary available in .NET
that could hold 2 keys and one value.
Like
Dictionary(Of TKey, Of TKey, TValue)
I have a need to store two keys and at certain times look an item by the key 1 and at other times by the key 2.
My current solution is to maintain two dictionaries
Dictionary<string, long> Dict1 = new Dictionary<string, long>();
Dictionary<long, long> Dict2 = new Dictionary<long, long>();
and when need to add item I will add it to both dictionaries.
Dict1.Add("abc", 111);
Dict2.Add(345, 111);
and then I will look up an item from either one of those dictionaries depending by which one of the keys I need to look by.
Same I will do when deleting or updating an item.
I have thought about the composite key but I don't know how to set it up and I don't want to lose any speed of searching the item.
Is there some solution available in .NET
to have dictionary that can hold multiple keys?
question from:
https://stackoverflow.com/questions/32761880/net-dictionary-with-two-keys-and-one-value 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…