What do I need to do to be able to call .ToArray () for a HashSet? I have tried the following but it did not work:
let a = System.Collections.Generic.HashSet ()
a.Add 5 |> ignore
a.ToArray () // Not possible
let b = a :> System.Collections.IEnumerable
b.ToArray () // Not possible
Here, this is stated:
ToArray : Creates an array from a IEnumerable. (Defined by Enumerable.)
so there should be a way.
IEnumerable.ToArray() is defined as an extension method under System.Linq.
Alternatively, use Seq.toArray or Array.ofSeq.