问题
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)?
回答1:
I think what you want is a HashSet<T>.
回答2:
HashSet<T> would work for this. It lets you store a unique set of values, without "abusing" a dictionary.
回答3:
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?
来源:https://stackoverflow.com/questions/692853/which-collection-for-storing-unique-strings