【问题标题】:Calling overloaded method in .net class does not work在 .net 类中调用重载方法不起作用
【发布时间】:2019-04-30 09:43:03
【问题描述】:

当尝试执行 .net 类的重载方法时,我总是收到参数数量不正确的错误。

.net 代码:

    public bool AddStock(double AWidth, double AHeight, int aCount)
    {
      return this.Manager.(AWidth, AHeight, aCount, string.Empty, 0);
    }

    public bool AddStock(double AWidth, double AHeight, int aCount, string aID)
    {
      return this.Manager.(AWidth, AHeight, aCount, aID, 0);
    }

    public bool AddStock(double AWidth, double AHeight)
    {
      return this.AddStock(AWidth, AHeight, 1);
    }

在 PHP 中:

这行得通:

$e->AddStock(2440, 1220, 1);

这不是:

$e->AddStock(2440, 1220, 1, 'Test');

致命错误:未捕获的 com_exception:错误 [0x8002000e] 参数数量无效。

【问题讨论】:

    标签: php .net overloading


    【解决方案1】:

    经过大量谷歌搜索后,我发现如果您添加下划线和数字,则可以访问重载方法。

    解决办法是

    $e->AddStock_3(2440, 1220, 1, 'Test');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-18
      • 2021-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多