izloch2
asked on
get fist element from dictionary in C#
Hi! Is there a simple way to return the first element from Dictionary. I'm trying to do it the following way but it doesn't work:
Dictionary<string, bool> temp = new Dictionary<string,bool>();
temp.Add("Z", false);
temp.Add("T", false);
temp.Add("A", false);
temp.Add("D", false);
string t = temp.GetEnumerator().Curre nt.Key;
I need to get t="Z" from the dictionary, but i get t equal to null
Thank you
Dictionary<string, bool> temp = new Dictionary<string,bool>();
temp.Add("Z", false);
temp.Add("T", false);
temp.Add("A", false);
temp.Add("D", false);
string t = temp.GetEnumerator().Curre
I need to get t="Z" from the dictionary, but i get t equal to null
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dictionary<string, bool>.KeyCollection keys = temp.Keys;
Now you can search the key collection for "Z".
Jim