There are two possible solutions I can think of:
First, assuming that your
Dictionary
entries are all really integer values, then define the
Dictionary
with
int
values, not as
string
:
Dictionary<string, int> _ABC = new Dictionary<string, int>();
Then store the values as integers and your reverse lookup will behave:
_ABC.Add("America", 54);
string emailAdd = _ABC.FirstOrDefault(x => x.Value == 94).Key;
This is
not efficient.
There is no order preserved! This is unpredictable if the values are not unique.
I think a better solution would be just to keep 2 Dictionary instances. The
_ABC
you have now (and it is still better to keep the Value as int if that is really the correct constraint on the values). And then a second one for the reverse mapping:
Dictionary<int, string> _ABCrev = new Dictionary<int, string>();
_ABCrev.Add(54, "America");
string emailAdd = _ABCrev[54];
Again, this counts on the numeric "values" being unique.