Prebuilt collection class?  
Author Message
kopo





PostPosted: Visual C# General, Prebuilt collection class? Top

Does .NET 2.0 have any pre-built (non-abstract) collection or dictionary classes

I'd like to have a simple collection with strings as indices and some custom objects as values, where I can add, remove, check if an item exists, and get an item by index.
I really don't want to have to implement all of the needed methods, but I haven't been able to find any ready-made collection classes in the .NET libraries.

Any ideas


Visual C#16  
 
 
kopo





PostPosted: Visual C# General, Prebuilt collection class? Top

To answer my own question, I found it:

System.System.Collections.Generic.Dictionary<key type, value type>


The implementation is a little unwieldy (separate ContainsKey() and ContainsValue() methods, for example), but it will have to do.

 
 
JThiloR





PostPosted: Visual C# General, Prebuilt collection class? Top

Concerning your last point:

There is also a "KeyValuePair". So you do not have the seperation between keys and values.


 
 
Matthew Watson





PostPosted: Visual C# General, Prebuilt collection class? Top

If you find the built-in collection classes to be insufficient for your needs, I recommend downloading PowerCollections from http://www.wintellect.com/PowerCollections.aspx.

It's free, and it's modelled somewhat on the STL collections (in that it has separate containers and algorithms). The guy that wrote it also contributed to .Net itself.

It really is very good.