F# 如何设置[<;Out>;]参数?

F# 如何设置[<;Out>;]参数?,f#,F#,我正在使用out参数:[]消息:string 但是当我试图设置它时:messageOut参数类似于ref-您需要像这样使用:=(取自MSDN文档) opensystem.Runtime.InteropServices;; 类型dummy()= 成员this.MyMethod([]x:ref)=x:=10;; 公开类型为byref且属性为[]的方法参数,并将地址为运算符&的可变值用作参数: open System.Runtime.InteropServices let mutable msg =

我正在使用out参数:
[]消息:string


但是当我试图设置它时:messageOut参数类似于ref-您需要像这样使用
:=
(取自MSDN文档)

opensystem.Runtime.InteropServices;;
类型dummy()=
成员this.MyMethod([]x:ref)=x:=10;;

公开类型为
byref
且属性为
[]
的方法参数,并将地址为运算符
&
的可变值用作参数:

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
open System.Runtime.InteropServices
让mutable msg=“abc”
let outmsg([]消息:byref)=

消息作为建议,并不是说您不能让out参数工作,而是尝试使用元组来从函数返回您需要的所有值。
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