hi all,
i have started recently learning c# and when i do some code using the hashtable, i could n't get the value of a particular key
we can get a value for a particular key but do we can do the verse ?
Yahia Farghaly
0
Newbie Poster
Recommended Answers
Jump to PostLoop the entries:
Hashtable hashtable = new Hashtable(); hashtable.Add("1", "one"); hashtable.Add("2", "TEST"); hashtable.Add("3", "one"); string key = string.Empty; foreach (DictionaryEntry entry in hashtable) { if ((string)entry.Value == "TEST") { key = (string)entry.Key; break; } } Console.WriteLine(key);
All 3 Replies
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
Yahia Farghaly
0
Newbie Poster
Lucaci Andrew
140
Za s|n
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.