I have a dictionary of type
and for a particular case, I need to do a reverse lookup. So for instance suppose I have this entry <\"S
Use the Linq ToDictionary
function:
var reversed = d.ToDictionary(x => x.Value, x => x.Key);
You can see below that it works, as tested in Linqpad:
var d = new Dictionary();
d.Add(1,"one");
d.Add(2,"two");
d.Dump(); //prints it out in linq-pad
var reversed = d.ToDictionary(x => x.Value, x => x.Key);
reversed.Dump(); //prints it out in linq-pad