我在 C# 代码中声明了两个类:
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)
{
...
}
}
虽然从 C# 调用B.TryParse
没有问题,因为正确的重载是由 out 参数类型决定的,应该提前声明。由于 out 参数是 F# 中结果的一部分的转换,我们得到了两个具有相同参数签名的函数......并且从 F# 调用会导致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.
错误。我理解这个问题,甚至会声明TryParse
为new
......如果它不是静态的。
消息本身并不是很有帮助:绝对不清楚要添加哪种注释以及在哪里添加。
我该怎么打这个电话?最愚蠢的想法是重命名函数之一,但可能有更聪明的方法?