let uriResult: System.Uri = ref (* what's here? *);
System.Uri.TryCreate(uriName, UriKind.Absolute, uriResult)
当我学会here时,必须传递.NET out 参数的F#引用。
但是如何在我的情况下初始化我的参考uriResult
?
我尝试过创建一个新的空Uri对象。
let uriResult: System.Uri = ref (new System.Uri());
错误1
该表达式预计具有类型
乌里
但这里有类型
'参考
答案 0 :(得分:11)
正如MSDN上的Parameters and Arguments中所述(请参阅参考传递),out参数会自动进行tuplized,因此您可以这样做:
match System.Uri.TryCreate(uriName, UriKind.Absolute) with
| true, uriResult -> //OK
| _ -> //not a Uri