Best Collection?

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

What's the best collection for the following scenario:

key value
--- -----

"Languages" -> "C#"
-> "Delphi"
-> "C++"

"IDEs" -> "VS.NET"
-> "BDS"
-> "KDevelop"

Basically we have a string /key/ with one of more string /values/.

I'd guess that 'NameValueCollection' would be usable here but is it the
best class for this?
 
C# Learner said:
What's the best collection for the following scenario:

key value
--- -----

"Languages" -> "C#"
-> "Delphi"
-> "C++"

"IDEs" -> "VS.NET"
-> "BDS"
-> "KDevelop"

Basically we have a string /key/ with one of more string /values/.

I'd guess that 'NameValueCollection' would be usable here but is it the
best class for this?

It's certainly an easy class to use, so long as you make sure you use
Add and GetValues rather than just the indexer.

Another alternative would be to use a Hashtable where the value was an
ArrayList of strings.
 
Jon Skeet [C# MVP] wrote:

[...]
It's certainly an easy class to use, so long as you make sure you use
Add and GetValues rather than just the indexer.

Another alternative would be to use a Hashtable where the value was an
ArrayList of strings.

Thanks Jon. The latter sounds like a good idea but I think I'll go with
the former in this instance.

Bye.
 
Back
Top