Need Collection of value pais which allow duplicate keys !!

  • Thread starter Thread starter Terry Burns
  • Start date Start date
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
 
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
 
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)
 
Back
Top