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)?
HashSets are used to store a collection of unique elements. HashSet cannot contain duplicate values. HashSet allows null value.
Store unique values in Java using Set interface The Set interface in Java allows allows maintaining unique list in Java. Here in this example we will use HashSet to maintain list of of unique values in our program. First of all we will initialize the HashSet object and then add few values including duplicates.
Thus, HashSet is a generic collection, that does not allow duplicates.
I think what you want is a HashSet<T>.
HashSet<T> would work for this. It lets you store a unique set of values, without "abusing" a dictionary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With