使用类型byref<string>和属性公开方法参数,[<Out>]并使用address-of运算符作为参数使用可变值&:
open System.Runtime.InteropServices
let mutable msg = "abc"
let outmsg ([<Out>]message : byref<string>) =
message <- "xyz"
msg <- "test"
outmsg(&msg)
msg;;
val mutable msg : string = "xyz"
val outmsg : byref<string> -> unit
Run Code Online (Sandbox Code Playgroud)