class CustomClass<T> where T: bool
{
public CustomClass(T defaultValue)
{
init(defaultValue); // why can't the compiler just use void init(bool) here?
}
public void init(bool defaultValue)
{
}
// public void init(int defaultValue) will be implemented later
}
Run Code Online (Sandbox Code Playgroud)
你好.这似乎是一个简单的问题,但我在互联网上找不到答案:为什么编译器不会使用init方法?我只想为不同类型提供不同的方法.
而是打印以下错误消息:"'CustomClass.init(bool)'的最佳重载方法匹配'有一些无效的参数"
我很乐意提示.
最好的问候,克里斯