Pass the `out` parameter (as a reference) to F #

I want to call System.Uri.TryCreate() :

 let uriResult: System.Uri = ref (* what here? *); System.Uri.TryCreate(uriName, UriKind.Absolute, uriResult) 

As I found out here , you need to pass the F # link for .NET parameters.

But how can I initialize my uriResult link in my case?

I tried to create a new empty Uri object.

 let uriResult: System.Uri = ref (new System.Uri()); 

Error 1
This expression should have type
Uri
but there is a type
'a ref

+4
source share
1 answer

As explained in Options and Arguments on MSDN (see "Passing by Link" section), the options are automatically configured, so you can do this:

 match System.Uri.TryCreate(uriName, UriKind.Absolute) with | true, uriResult -> //OK | _ -> //not a Uri 
+10
source

Source: https://habr.com/ru/post/1491460/


All Articles