Reputation: 4762
I have an obj[,]
whose components are all float
s. I want to convert it to a float[,]
. I tried many permutations of box
, unbox
, Array2D.map float
, Array2D.copy
, System.Convert.ChangeType
, etc and none seem to work. How to proceed?
Upvotes: 0
Views: 690
Reputation: 40818
This seems to work just fine for me:
let boxedArray = Array2D.init 2 2 (fun x y -> box (float (x + y)))
let unboxedArray = boxedArray |> Array2D.map unbox<float>
printfn "%A" (boxedArray.GetType()) // System.Object[,]
printfn "%A" (unboxedArray.GetType()) // System.Double[,]
Upvotes: 3