Is there a dictionary available in .NET
that could hold 2 keys and one value.
Like
Dictionary(Of TKey, Of TKey, TValue)
I have
As you wish your value to be “findable” from either key, I would just use two dictionaries like you are doing now. However I would wrap this up in a class, with methods names like FindByXXX
and FindByYYY
.
The much harder question is how do you do a delete, as you need to know both keys at the time of the delete. Maybe your value stores both keys so you can pass the value into your delete method. Maybe you never need to remove items from the dictionaries. Or the code that needs to remove items knows both keys.
Hence there is no standard dictionary to do this, as the requirements are different between each user.
(Note you don’t want a dictionary with a composite key, as that would require you to know both keys whenever you wished to look up an item.)