Need Collection of value pais which allow duplicate keys !!

T

Terry Burns

I want to use a collection of value pairs but dont want to be restricted to
unique keys. Does anyone know how I can do this.

I dont want to use an array because I need the flexibility of a collection
to allow growing or shrinking lists.

Regards
 
J

Jay B. Harlow [MVP - Outlook]

Terry,
Have you looked at all the collections in System.Collections &
System.Collections.Specialized?

ArrayList is an array like collection that has the flexibility to allow
growing or shrinking lists.

HashTable allow key/value pairs, however the key must be unique.

The NameValueCollection 'stores multiple string values under a single key',
its based on NameObjectCollectionBase, which has an underlying structure of
a hashtable.

If I'm reading your question correctly, you want to use the NameValue
Collection.

Hope this helps
Jay
 
C

Chris Dunaway

I want to use a collection of value pairs but dont want to be
restricted to unique keys. Does anyone know how I can do this.

I dont want to use an array because I need the flexibility of a
collection to allow growing or shrinking lists.

Regards

ONe method would be to use an ArrayList and then populate with instances of
a structure For example (air code):

Public Structure ValuePair
Public Value As Integer
Public Data As String
End Structure

Dim al As New ArrayList
Dim vp As ValuePair

vp.Value = 1
vp.Data = "One"

al.Add(vp)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top