【发布时间】:2011-01-22 15:24:08
【问题描述】:
在 C# 中我可以做到:
var castValue = inputValue as Type1
在 F# 中,我可以做到:
let staticValue = inputValue :> Type1
let dynamicValue = inputValue :?> Type1
但它们都不等同于 C# 的关键字 as。
我想我需要为 F# 中的等价物做一个匹配表达式
match inputValue with
| :? Type1 as type1Value -> type1Value
| _ -> null
这是正确的吗?
【问题讨论】: