Is there a dictionary available in .NET that could hold 2 keys and one value.
Like
Dictionary(Of TKey, Of TKey, TValue)
I have
Your solution has a big impact on the memory footprint of your application. As the dictionary grows it will take at least double the amount memory (for value types) required to store the actual data.
You could probably approach this from a different angle. Have two dictionaries :
var lookupDictionary = new Dictionary();
var valuesDictionary = new Dictionary();
From here on in its pretty simple.
// Add a new entry into the values dictionary and give it a unique key
valuesDictionary.Add("FooBar", "FUBAR VALUE");
// Add any number of lookup keys with the same value key
lookupDictionary.Add("Foo", "FooBar");
lookupDictionary.Add("Bar", "FooBar");
lookupDictionary.Add("Rab", "FooBar");
lookupDictionary.Add("Oof", "FooBar");
When you need to find something from valuesDictionary you hit lookupDictionary first. This will give you the key of the value you are looking for in the valuesDictionary.
EDIT
I haven't addressed the deletion issue in my answer so here it goes :D
You would hit lookupDictionary to find the value key and then delete all entries from lookupDictionary that have that value.
Should be simple enough and safe since the valuesDictionary is guaranteed to have a unique key hence you will not accidentally delete a lookup key for some other value.
However, as Ian Ringrose pointed out in a comment, you are going to do a full scan on the lookupDictionary to delete. This may have an undesirable impact on performance in tight loops etc.
I can't really think of a good way to solve this issue at the moment. Perhaps someone else might have some ideas on how this could be improved.
I hope this helps.