Hi all,
having a dictionary of <int, string(C# 2.0) is there a way to retrieve the
key for a specific value (of type string)?
Obviously I populate the Dictionary with not duplicated strings.
Thanks a lot.
dictionnaries are "one way". you'll have to iterate or use a second
dictionnary.
You said you're using C# 2.0, so just to show you what C#3.0 can bring,
you can simplify your code using a Linq query like this (case
insensitive search of string "two" in a dictionnary "dic"
dictionnary<int,string>) :
var key = (from k in dic where string.Compare(k.Value, "two", true) ==
0 select k.Key).FirstOrDefault();
Console.WriteLine(key);
--
OD___
www.e-naxos.com