473,395 Members | 1,987 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,395 software developers and data experts.

Numeric index into HashTable

I'm looking for a way to step through a hashtable while adding items
to the table (This precludes using enumerators. They don't like
HashTable alterations while they are active). There must be an
internal structure that can be accessed sequentially, like an array.
Is it accessible?

Or maybe there is another construct that will allow this. The main
reason I'm using a HashTable is to eliminate duplicate entries.
(This is why I had posted a query about DataTables for this)

Nov 15 '05 #1
1 9929
Hi _eee_,

"_eee_" <_n****@nomail.com> wrote in message
news:qr********************************@4ax.com...
I'm looking for a way to step through a hashtable while adding items
to the table (This precludes using enumerators. They don't like
HashTable alterations while they are active). There must be an
internal structure that can be accessed sequentially, like an array.
Is it accessible?

Or maybe there is another construct that will allow this. The main
reason I'm using a HashTable is to eliminate duplicate entries.
(This is why I had posted a query about DataTables for this)


You could do it like this:

Hashtable hashTable = new Hashtable();
hashTable["foo"] = "bar";

object[] keys = new object[hashTable.Count];
hashTable.Keys.CopyTo(keys, 0);

for (int i = 0; i < keys.Length; i++)
{
Console.WriteLine("Key is {0}. Value is {1}",
keys[i].ToString(),
hashTable[keys[i]].ToString());
}

Regards,
Dan
Nov 15 '05 #2

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

Similar topics

1
by: Nicolas Pernetty | last post by:
Hello, I'm trying to find a clear and fast equivalent to the index method of plain python list : >> a = >> a.index(4) 2 I have to use it on a Numeric array, so the best I've come up with...
2
by: Gregg Teehan | last post by:
Suggestions on best practive for array declare / subscript using an enum - this is easy in Delphi / Object Pascal. I want private MyObjectClass myObjects; myObjects = new MyObjectClass ;...
8
by: Dgates | last post by:
Has anyone typed up an index for the O'Reilly book "C# and VB.NET Conversion?" I'm just learning C#, and often using this little book to see which VB.NET terms translate directly to some term in...
6
by: Andrew Robinson | last post by:
given a Hashtable and an Index, how do I retrieve the key? Hashtable h = new Hashtable(); h.Add("red", 3); h.Add("blue", 99); h.Add("green", 33); how do I get the key at index 2? h.Keys...
1
by: Dino Buljubasic | last post by:
Hi, Can somebody help me with this problem please. I need to get the value, not just to check for it, of a number pressed but it has to work for both, numbers above QUERTY and numbers entered...
14
by: Rich | last post by:
Yes, I need to store some values in an array type collection object that can hold 3 or more parameters per index. I have looked at the collection object, hashtable object and would prefer not to...
7
by: Sheldon | last post by:
Hi, I have the following loop that I think can be written to run faster in Numeric. I am currently using Numeric. range_va = main.xsize= 600 main.ysize= 600 #msgva is an (600x600) Numeric...
2
by: Deepa Jeevagan | last post by:
Hi, The application I am currently working on is developed in Oracle 8i. I have a table which has a nullable numeric column say CustNo. This column has an index defined on it and oracle uses...
1
by: ntabb | last post by:
Hello All, I have a hashtable of nodes that need to be added to a tree. The hash table's values contain an object that holds the node's Level, Index, and Text. The table keys names of the node. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.