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

Saving pairs in memory

Hi

I have a list of value pairs as below;

Section Name Section Type
A1111 Z9999
B2222 Y8888
C3333 X7777

What is a good intuitive way to store this information in memory? I was
thinking a two-dimensional array of strings, is there a better way?

Thanks

Regards
Dec 25 '07 #1
5 1092
On 25/12/2007 in message <#h**************@TK2MSFTNGP05.phx.gblJohn wrote:
>Hi

I have a list of value pairs as below;

Section Name Section Type
A1111 Z9999
B2222 Y8888
C3333 X7777

What is a good intuitive way to store this information in memory? I was
thinking a two-dimensional array of strings, is there a better way?
Will you need to look up a value from a key? If so perhaps a hashtable?

--
Jeff Gaines
Dec 25 '07 #2

"John" <Jo**@nospam.infovis.co.ukwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
Hi

I have a list of value pairs as below;

Section Name Section Type
A1111 Z9999
B2222 Y8888
C3333 X7777

What is a good intuitive way to store this information in memory? I was
thinking a two-dimensional array of strings, is there a better way?

Thanks
Simplest way is with two parallel one-dimensional arrays.
Another way is as an array of structures.
I also liked Jeff's solution.
His question has merit - how will you be accessing the elements?
Dec 26 '07 #3
John,

For versions behind 2003

\\\
........................
Private Sub Routine()
Dim myPairs As New List(Of Pairs)
myPairs(0).First = "A1111"
myPairs(0).Second = " Z9999"
End Sub
End Class
Class Pairs
Private mFirst As String
Private mSecond As String
Public Property First() As String
Get
Return mFirst
End Get
Set(ByVal value As String)
mFirst = value
End Set
End Property
Public Property Second() As String
Get
Return mSecond
End Get
Set(ByVal value As String)
mSecond = value
End Set
End Property
End Class
///

Cor
Dec 26 '07 #4
"John" <Jo**@nospam.infovis.co.ukwrote in news:#h#7AJ0RIHA.5524
@TK2MSFTNGP05.phx.gbl:
Hi

I have a list of value pairs as below;

Section Name Section Type
A1111 Z9999
B2222 Y8888
C3333 X7777

What is a good intuitive way to store this information in memory? I was
thinking a two-dimensional array of strings, is there a better way?

Generic Dictionary or a hashtable.

--
sp**********@rogers.com (Do not e-mail)
Dec 26 '07 #5
"Hal Rosser" <hm******@bellsouth.netwrote in news:ishcj.30643
$v********@bignews8.bellsouth.net:
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
>Hi

I have a list of value pairs as below;

Section Name Section Type
A1111 Z9999
B2222 Y8888
C3333 X7777

What is a good intuitive way to store this information in memory? I
was
>thinking a two-dimensional array of strings, is there a better way?

Thanks

Simplest way is with two parallel one-dimensional arrays.
With hashtables and dictionary... it's a bit amateurish to use two
parallel arrays.
Another way is as an array of structures.
I also liked Jeff's solution.
His question has merit - how will you be accessing the elements?
Hashtable("SectionName") = Type

A generic dictionary can store different data types too.

Or, you could create an array of custom objects which store SectionName
/ Section Type.
--
sp**********@rogers.com (Do not e-mail)
Dec 26 '07 #6

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

Similar topics

138
by: theodp | last post by:
--> From http://www.techdirt.com/articles/20040406/1349225.shtml Microsoft Patents Saving The Name Of A Game Contributed by Mike on Tuesday, April 6th, 2004 @ 01:49PM from the...
2
by: Gerald Maher | last post by:
Hi Reading in XML file, changing elements and saving back to the file, how can i do that, I want to be able to read an XML file and read out Elements. for example <name>Tom</tom> When I...
4
by: John Kandell | last post by:
Hi, I posted this in the asp.net group, but didn't get a response. Maybe someone here can help me with this... --- Would someone be able to shed some light on what is the cost of saving a...
3
by: Mats Boberg | last post by:
Hi, I have problems with saving a bitmap to hdd from my asp.net page I get the following error: "A generic error occurred in GDI+." Code: Bitmap bmp = new Bitmap(240,120);
1
by: Tom | last post by:
I have a large application; lots of forms, multiple dynamic DLLs, etc. I also have, in the appliation, a general 'Preferences' class object (which is in itself a separate DLL, and I just include a...
0
by: Christopher Kurtis Koeber | last post by:
Dear All, I am having problems saving an image to a memory stream to use it in an API function. The error occurs in the save method of the bitmap. It tells me that the arguement cannot be...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
6
by: Paul Bilokon | last post by:
Hi, Is there a more elegant and/or efficient way of saving the keys from a hash_map in a vector? Perhaps using assign or other algorithms? The problem, of course, is that we are dealing with an...
15
by: mcjason | last post by:
I saw something interesting about a grid pair puzzle problem that it looks like a machine when you find each that work out the way it does and say with all the others that work out the way they...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...

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.