title: Get internal array of HashSet<T> in C#
body: <p>I need a datastructure that has O(1) insert and remove operations and from which I can retrieve a random element at O(1).</p>
  <p>I thought of using HashSet in C#. Insert and remove operations are constant and I would be able to also get a random element from it if I could access the internal array. I don't want to create an array from the set, that would take O(n) every time.</p>
  <p>So my question is, is there a way to access the internal array of a HashSet? Or is there a better datastructure that meets the requirements?</p>
  <p><em>Note</em>: for example a Dictionary&lt;TKey, TValue&gt; allows to access the internal array for the keys and the values. It would be awesome if a HashSet had this too. I could use a Dictionary, but I wouldn't really use it for the mapping feature, which requires twice as much space as a HashSet.</p>