Link to home
Start Free TrialLog in
Avatar of steve_mick972
steve_mick972

asked on

HashTable Remove - Search Functionality.

Hi,

Here is my Hashtable.

HasTable myHash = new HashTable();

myHash.Add("~Chapter1-example1","A");
myHash.Add("~Chapter1-example2","B");
myHash.Add("~Chapter1-example3","C");
myHash.Add("~Chapter1-example4","D");


myHash.Add("~Chapter2-example1","A");
myHash.Add("~Chapter2-example2","B");
myHash.Add("~Chapter2-example3","C");
myHash.Add("~Chapter2-example4","D");
myHash.Add("~Chapter2-example5","E");



How can i remove all elements with key = "~Chapter1-"

kind of like a partial search, just want to remove all the keys, that start with the following key.



thanks,
steve.
ASKER CERTIFIED SOLUTION
Avatar of dfiala13
dfiala13

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Troy_Lyne
Troy_Lyne

Nest hashtables:

myHashCh1.Add("example1","A");
myHashCh1.Add("example2","B");
myHashCh1.Add("example3","C");
myHashCh1.Add("example4","D");

myHashCh2.Add("example1","A");
myHashCh2.Add("example2","B");
myHashCh2.Add("example3","C");
myHashCh2.Add("example4","D");
myHashCh2.Add("example5","E");

myHash.Add("~Chapter1-", myHashCh1);
myHash.Add("~Chapter2-", myHashCh2);