Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个obj[,]其组件都是floats 的。我想将其转换为float[,]. 我尝试了许多, , , , 等的排列box,但似乎都没有。如何进行?unboxArray2D.map floatArray2D.copySystem.Convert.ChangeType
obj[,]
float
float[,]
box
unbox
Array2D.map float
Array2D.copy
System.Convert.ChangeType
这对我来说似乎很好用:
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[,]