我需要分配给一个byref参数,但在Windows 8x64盒子上使用F#4.0和.NET 4.5.2,我总是收到我不能更改签名的投诉,因为我实现一个COM接口。最小破例如:F#byref param不可变
module Utils =
let bugFix1([<System.Runtime.InteropServices.Out>] ID : System.String byref) = ID <- "Hi!"
let bugFix1([<System.Runtime.InteropServices.Out>] ID : int byref) = ID <- 0
let bugFix1([<System.Runtime.InteropServices.Out>] ID : System.Guid byref) = ID <- System.Guid.NewGuid()
通过this value
,它肯定意味着ID
,因为它并不重要我分配到ID
。还要注意,这个类型是否可以启动,或者是堆栈还是堆栈分配都没有关系。
有什么办法可以申报ID
为mutable
?
也许是重复或至少类似http://stackoverflow.com/questions/946338/f-how-do-i-declare-and-use-byref-semantics-on-parameters –
什么F#版本你使用? –
@FyodorSoikin好点 - 4.0。我已经编辑了这个问题。 –