I need to convert a F# map class to a System.Collections.Hashtable for use by C#.
This question is not the same as the following: http://stackoverflow.com/questions/3032298/how-do-you-use-get-values-from-keys-add-items-hashtables-in-f
That question asked how to return values from a hashtable. I want to build an F# map and then convert it to a System.Collections.Hashtable.
How do I do this?
Thanks very much.
Here is what I have tried (does not compile):
#light
open System
open System.Collections
open System.Collections.Generic
let my_map = dict [(1, "one"); (2, "two")]
let myHash = Hashtable()
my_map |> Map.iter (fun k v -> myHash.Add(k, v) )
Edit: Thanks for your answers. Here is what I decided to use:
let my_map = Map [(1, "one"); (2, "two")]
let myHash = Hashtable()
my_map |> Map.iter (fun k v -> myHash.Add(k, v))