views:

248

answers:

3

I'm looking for a collection just like Dictionary(OF Key, Value) but I don't actually need a key and value. Key itself is enough. So something like Collection(Key). It shouldn't accept duplicate keys.

I've looked up couple of collections in .NET Framework but couldn't find what I want. Currently I'm abusing Dictionary(OF String, String) and setting Value as Nothing all the time.

Shall I just continue abusing Dictionary(OF T,T)?

+11  A: 

I think what you want is a HashSet<T>.

tvanfosson
+1  A: 

HashSet<T> would work for this. It lets you store a unique set of values, without "abusing" a dictionary.

Reed Copsey
+2  A: 

List would be better than Collection as noted in this semi-duplicate question.

A hashset in 3.5 would be better still. What version of .net are you using?

Michael Haren