Get the memory address of Array in F#

It's not convenient to get the memory address of object in F#, and the following code will illustrate how to get the memory of given index item of an array:

//Define your array
let arr = [|1;23|]
//Get the nativeint of arr.[0]
let nativeint = System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(arr,0)
//Construct a intptr using the nativeptr<unit> 
let intptr = new System.IntPtr(nativeint.ToPointer())
原文地址:https://www.cnblogs.com/FsharpZack/p/2758805.html