using hashtable key collection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zybernau
    New Member
    • Mar 2007
    • 34

    using hashtable key collection

    i need to retrieve a value from hash table key collection..

    can you guys explain me how..

    thanks
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    You could loop through your hashtable and search for the key value pair you want then exit the loop once you find the value.

    Code:
    foreach(DictionaryEntry de in hashtableName)
    {
      if(de.Value.ToString() == "thevalueuwant")
      {
        //do something:
        break;
      }
    }
    Or you could use an enumerator to move through the hashtable

    Code:
    IDictionaryEnumerator enumerator = hashtableName.GetEnumerator();
    while(enumerator.MoveNext())
    {
    if(enumerator.Value.ToString() == "thevalueuwant")
    {
       //do something;
       break; 
    }
    }
    Nathan

    Comment

    Working...