PC Review


Reply
Thread Tools Rate Thread

Saving pairs in memory

 
 
John
Guest
Posts: n/a
 
      25th Dec 2007
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


 
Reply With Quote
 
 
 
 
Jeff Gaines
Guest
Posts: n/a
 
      26th Dec 2007
On 25/12/2007 in message <#h#(E-Mail Removed)> John 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
 
Reply With Quote
 
Hal Rosser
Guest
Posts: n/a
 
      26th Dec 2007

"John" <(E-Mail Removed)> wrote in message
news:%23h%(E-Mail Removed)...
> 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?


 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      26th Dec 2007
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
 
Reply With Quote
 
Spam Catcher
Guest
Posts: n/a
 
      26th Dec 2007
"John" <(E-Mail Removed)> wrote 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.



--
(E-Mail Removed) (Do not e-mail)
 
Reply With Quote
 
Spam Catcher
Guest
Posts: n/a
 
      26th Dec 2007
"Hal Rosser" <(E-Mail Removed)> wrote in news:ishcj.30643
$(E-Mail Removed):

> "John" <(E-Mail Removed)> wrote in message
> news:%23h%(E-Mail Removed)...
>> 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.


--
(E-Mail Removed) (Do not e-mail)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory Pairs mcp6453 Windows XP Hardware 2 15th Jun 2008 12:06 AM
Saving pairs in memory John Microsoft VB .NET 5 26th Dec 2007 04:34 PM
DDR2 memory---must it be bought in pairs? TheKeith Processors 7 26th Oct 2004 12:00 AM
EDO memory matched pairs JM DIY PC 8 5th Feb 2004 03:25 AM
interpolation: unevenly spaced x-y data pairs --> evenly spaced data pairs =?Utf-8?B?ei5lbnRyb3BpYw==?= Microsoft Excel Worksheet Functions 1 13th Dec 2003 11:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:45 PM.