ASP.NET - HashTable problem - Asked By mostafa hamdy on 14-Mar-12 01:04 PM

Hello all
I have some Hashtable like the following:

Hashtable htCloseLocation = new Hashtable();

htCloseLocation.Add("1", "Phone");

htCloseLocation.Add("2", "On Site");

htCloseLocation.Add("3", "CRUR");

htCloseLocation.Add("4", "CRURN");

htCloseLocation.Add("5", "Carry In");

htCloseLocation.Add("6", "TC");


and I want to get the value by the hash key or get the key by value like the following:

Name = htCloseLocation[1].ToString();
or
Name = (string)htCloseLocation[1];
I get the Name as null
please if any body can help me please send me or tell me about some URL may help me in doing that\
Regards
Mostafa

Rolf Jaeger replied to mostafa hamdy on 14-Mar-12 01:25 PM
Hi Mostafa:

it seems to me that you should be using the key string instead of an integer. This should work:

Name = htCloseLocation["1"].ToString(); 

Hope this helped,
Rolf
Rolf Jaeger replied to mostafa hamdy on 14-Mar-12 01:25 PM
Hi Mostafa:

it seems to me that you should be using the key string instead of an integer. This should work:

Name = htCloseLocation["1"].ToString(); 

Hope this helped,
Rolf