473,399 Members | 2,146 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,399 software developers and data experts.

Embedded Hashtables

Does anyone know the proper method to save information to embedded
hashtables.

I am trying to save parent/child information to hashtables but I am not
getting the correct results I have made a very simplified example of
problem with the following code:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Add(1, "500")
invoiceLines.Add(2, "1000")
invoice.Add("Inv123", invoiceLines)
cust.Add("ABC", invoice)
invoiceLines.Clear()
invoice.Clear()
invoiceLines.Add(1, "123")
invoiceLines.Add(2, "10")
invoice.Add("Inv222", invoiceLines)
cust.Add("BBB", invoice)

Is there a way to correctly save this information so that it doesn't delete
the values of the first hashtables that I want saved into the cust hashtable
when I do a clear?

Thanks,
Curtis
Nov 21 '05 #1
1 1494
I solved my problem by using the .clone method of the hashtables like so:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Add(1, "500")
invoiceLines.Add(2, "1000")
invoice.Add("Inv123", invoiceLines.Clone)
cust.Add("ABC", invoice.Clone)
invoiceLines.Clear()
invoice.Clear()
invoiceLines.Add(1, "123")
invoiceLines.Add(2, "10")
invoice.Add("Inv222", invoiceLines.Clone)
cust.Add("BBB", invoice.Clone)

Curtis

"Curtis" <cs*****@hotmail.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
Does anyone know the proper method to save information to embedded
hashtables.

I am trying to save parent/child information to hashtables but I am not
getting the correct results I have made a very simplified example of
problem with the following code:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Add(1, "500")
invoiceLines.Add(2, "1000")
invoice.Add("Inv123", invoiceLines)
cust.Add("ABC", invoice)
invoiceLines.Clear()
invoice.Clear()
invoiceLines.Add(1, "123")
invoiceLines.Add(2, "10")
invoice.Add("Inv222", invoiceLines)
cust.Add("BBB", invoice)

Is there a way to correctly save this information so that it doesn't
delete the values of the first hashtables that I want saved into the cust
hashtable when I do a clear?

Thanks,
Curtis

Nov 21 '05 #2

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

Similar topics

0
by: Aaron | last post by:
I am not sure the appropriate newsgroup for this question,...I have also posted this on the XML.SOAP foru Within a VB.NET application, I have two objects that are serializable. The second object...
6
by: Michael Schollmeyer | last post by:
Hello, The following code writes the text string: Uri uri1 = new Uri("http://www.here.net/aplace?param=one"); Uri uri2 = new Uri("http://www.here.net/aplace?param=two"); int h1 =...
13
by: Anders Borum | last post by:
Hello! Now that generics are introduces with the next version of C#, I was wondering what kind of performance gains we're going to see, when switching from e.g. the general hashtable to a...
4
by: Anders Borum | last post by:
Hello! I have a list of singleton classes (model managers) that store objects internally using hashtables. Each of these classes use a single hashtable to store e.g. users, pages, elements and...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
7
by: Kamran Shafi | last post by:
Hi, I am creating an arraylist (say masterArrayList) of hashtables, where each hashtable (say table) is of the format key=string, value = arraylist of strings (say existing_strings). In a...
7
by: Mike P | last post by:
I have 2 hashtables each of which I am using to store a set of IDs and Descriptions. Hashtable 1 will have the full set of data (e.g. IDs 1,2,3,4,5) whereas Hashtable 2 will only have a subset of...
0
by: John Smith | last post by:
Hello people, I have a performance query regarding LINQ that I would like some opinions. Currently we have a business logic framework that is used in n-tier applications. We read data from a...
0
by: Jake McCool | last post by:
Hello people, I have a performance query regarding LINQ that I would like some opinions. Currently we have a business logic framework that is used in n-tier applications. We read data from a...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.