Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about hashtable

Status
Not open for further replies.

chenshch

Technical User
Jun 9, 2004
8
CN
hello
Is there a simple and easy way to make all values in hashtable have the same value?
i think there should be,but i don't know.
if you know ,please tell me
thanks
 
I understand that you construct a hashtable and next you want to set all values to a unique value.
It is possible like here:
Code:
Hashtable ht = new Hashtable();
ht["joe"]="Test1";

ht["john"]= new System.Diagnostics.Process();

ht["epsilon"]=Double.Epsilon;

ht["pi"]=3.14159;

ht["2004-07-10"]= new System.Timers.Timer(1000);

ArrayList kList = new ArrayList();
foreach (object obj in ht.Keys)
{
	kList.Add(obj);
}
foreach (object k in kList)
{
	ht[k]="blabla"; // all values will be strings set to "blabla"
	
}
-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top