The F# equivalent of C#'s 'out'

前端 未结 4 1011
小蘑菇
小蘑菇 2020-12-09 18:30

I am rewriting a C# library to F# and I need to translate the following code

bool success;
instance.GetValue(0x10, out success);

what is th

4条回答
  •  一向
    一向 (楼主)
    2020-12-09 19:00

    You have to use a reference cell.

    let success = ref false
    instance.GetValue(0x10, success)
    
    // access the value
    !success
    

提交回复
热议问题