Special hashtable?

B

Boni

Dear all,
I need a hashtable, where the value and the key is the same,or better said I
need an array, where I can't add the same object 2 times. The access to
elemts, which I need is only "for each element in Collection..."

What is the best collection for that.

I.e.
MyCollection.add(oA1)
MyCollection.add(oA2)
MyCollection.add(oA3)

But one more addition of the same object should fail,
MyCollection.add(oA1) 'should throw an exception.

The obvious workaround is dim MyCollection as Hashtable
sub Add( arg)
MyCollection(arg,arg)
end sub

main
Add(oA1)
Add(oA2)
Add(oA3)
end

Are there better solutions?
 
C

Chris Dunaway

Look in the System.Collections.Specialized namespace. There are
probably some classes there that will fit your needs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top