473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Modifying Hashtable values

Hi all,

I used all your info to come up with the following conclusion when I needed to modify my Hashtable object.

1) Create an ArrayList from the Hashtable keys so that we have something to iterate around without involving the Hashtable.
2) Use a foreach or a for loop to iterate around each ArrayList item and change the Hashtable values as we need.

ArrayList keyList = new ArrayList(myHashTable);
for (int i=0; i < myHashTable.Count; i++)
{
string key = (string)keyList[i];
myHashTable[key] = "Change" + i;
}

This assumes that the Hashtable values are string objects but of course they can be any object!
Hope this helps.

--------------------------------
From: John Meredith

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>uWPT3M12R0KMmvk7pl5b/Q==</Id>
Jul 21 '05 #1
0 1201

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: suresh | last post by:
Hi all, I have a hash table and I want to modify the value of a key. Please let me know how can that be acheived. Thanks Suresh
6
by: VidalSasoon | last post by:
I have a singleton class that I want to only contain a hashtable. I want to be able to modify this hashtable at will. The problem I am having is each time I try to update the data using the...
8
by: SenthilVel | last post by:
how to get the corresponding values for a given Key in hashtable ??
16
by: Sreekanth | last post by:
Hello, Is there any better collection than HashTable in terms of performance, when the type of the key is integer? Regards, Sreekanth.
8
by: Robin Tucker | last post by:
When I create a hashtable hashing on Object-->Item, can I mix "string" and "integer" as the key types? I have a single thumbnail cache for a database with (hashed on key) and a file view (hashed...
4
by: Slonocode | last post by:
I have a hashtable full of objects. There seems to be no way to get an object from the hashtable and modify it. Are collections or hashtables in particular not meant for this kind of operation?
0
by: John Meredith via .NET 247 | last post by:
Hi all, I used all your info to come up with the following conclusion when I needed to modify my Hashtable object. 1) Create an ArrayList from the Hashtable keys so that we have something to...
2
by: bandroo | last post by:
Hi Guys How can I modify the items within a hashtable "in situ" so to speak? At the moment, I am locating the item that I want, extracting it, modifying the item, deleting the hashtable item,...
3
by: NagarajanS | last post by:
Hi, i need one help in HashTable. see the below example /* * HashTableTest.java * * Created on October 20, 2007, 12:48 PM * * To change this template, choose Tools | Template Manager *...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.