John, thanks very much but if i understand i have also to maintain this key collection because i have to add and remove items .
Maybe i have not given the question on a good way. My problem is in fact :
The items are JUST a set of random integers, nothing more and I have to do (find ad random an item, add and remove) but millions many times.
I found that a dictionary is very fast for adding and removing to do that but taking an item ad random looks a problem for a fast time.
My question is thus :
With a set of integers and to find ad random an item, or add an item or remove an item so very fast as possible what should i use as method?
A list do that but it looks not very fast, are there other posibilities for doing this in a faster way.
Thanks for any response.
As for the issue, are you saying that you don't actually want to store keys and values but simply a collection of random Integer values? If so then use a HashSet(Of Integer). It is like a cross between a List(Of Integer) and the Keys collection of a Dictionary. It has Add, Contains and Remove methods. The Add method won't add duplicates and returns False in that case.