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

Need Collection of value pais which allow duplicate keys !!

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
Nov 19 '05 #1
2 10933
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

"Terry Burns" <te*********@BTOpenworld.com> wrote in message
news:be**********@sparta.btinternet.com...
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

Nov 19 '05 #2
"Terry Burns" <te*********@BTOpenworld.com> wrote in
news:be**********@sparta.btinternet.com:
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)

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail
Nov 19 '05 #3

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

Similar topics

3
by: Kakaiya | last post by:
Error message: An unhandled exception of type 'System.InvalidCastException' occurred in test.dll Additional information: Specified cast is not valid. Public Class Form1 Inherits...
7
by: juli | last post by:
I have strings variables in a collection list and I want to create new collection but to add to it only strings that are distinct (no common strings). For example I have an object sentense which...
7
by: Dan | last post by:
I have the need to translate values back and forth. I have created a Hashtable to do this because I don't care about intrinsic order and I want it to be a fast as possible. My only concern is...
2
by: Hazzard | last post by:
I am trying to figure out how to add an additional value to a querystring collection so that when I click on a datagrid cell, there will be a key to distinguish it from another column's...
3
by: Mike | last post by:
Hi guys; I created a class that inherits from DictionaryBase class. The thing is that I want to allow the user when using my class to enter duplicate keys in the collection like; Dim myCl as...
6
by: Mike | last post by:
Hello guys, how are you? I implemented a class called MyDictionary that inherits from DictionaryBase. The thing is that my class, cannot handle a duplicate value in the "keys"
6
by: Burt | last post by:
I need to create a collection of classes (or structures) can be accessed by a string key, eg MyColl("ShortName5").Name for class with key ShortName5. But it also has to be sorted by a second...
5
by: MJ | last post by:
Hello, I need some suggestions on how to do this. I am reading through a large iis loge. For each line, I get three datapoints (sessionID, Time, Stage). I need to store these values into some...
20
by: Seongsu Lee | last post by:
Hi, I have a dictionary with million keys. Each value in the dictionary has a list with up to thousand integers. Follow is a simple example with 5 keys. dict = {1: , 2: , 900000: , 900001:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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?
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...

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.