更新时间:2023-11-29 13:38:10
Chris 的回答是正确的,如果您确实需要通过引用传递可变的 DateTime
.但是,在 F# 中使用编译器将尾随 out
参数视为元组返回值的能力更为惯用:
Chris's answer is correct if you really need to pass a mutable DateTime
by reference. However, it is much more idiomatic in F# to use the compiler's ability to treat trailing out
parameters as tupled return values:
let couldParse, parsedDate = System.DateTime.TryParse("11/27/2012")
这里,第一个值是 bool
返回值,而第二个值是分配的 out 参数.
Here, the first value is the bool
return value, while the second is the assigned out parameter.