F #: how to specify static overload to use?

I have two classes declared in C # code:

public class A
{
     public static bool TryParse(string value, out A result)
     {
         ...
     }
}

public class B : A
{
     public static bool TryParse(string value, out B result)
     {
         ...
     }
}

When calling B.TryParsefrom C #, this is not a problem, since the correct overload is determined by the type of parameter that must be declared in advance. Since the out parameter is a conversion to part of the result in F #, we got two functions with the same parameter signature ... And a call from F # causes an error A unique overload for method 'TryParse' could not be determined based on type information prior to this program point. A type annotation may be needed.. I understand this problem and even declare TryParsehow new... If it was not static.

The message itself is not very useful: it absolutely does not recognize which annotation and where to add it.

How can I make this call? The dumbest idea is to rename one of the functions, but maybe there is a smarter way?

+3
source
2

, try, out, , . , - :

let res, (b:B) = B.TryParse "MyString"

F # (:).

(: F # out )

+4

:

  • ( ).
  • , , out, , "" "B"; , "B" ( ).
  • , TryParse , .
+3

All Articles