简体   繁体   English

方法'METHOD'没有重载需要0个参数

[英]no overload for method 'METHOD' takes 0 arguments

I have 3 methods. 我有3种方法。

1 method holding the value of 3000 1 method holding the value of 0.13 1方法保持值为3000 1的方法保持值为0.13

and I have created another method that I want to multiply these two figures together. 我已经创建了另一种方法,我希望将这两个数字相乘。

public override int FishPerTank()
{                
    return 3000;                
}

public override double WeightOut(double weightOut, double weightIn)
{
    return 0.13;
}

public override int HowMuchTheFishWeighOutKG()
{
    return (FishPerTank() * WeightOut());
}

I am receiving the syntax error on the WeightOut here: 我在这里收到WeightOut上的语法错误:

public override int HowMuchTheFishWeighOutKG()
{
    return (FishPerTank() * WeightOut());
}

WeightOut 2个参数而你没有提供它们

WeightOut(double weightOut, double weightIn) is declared with two parameters and you're calling it with none. WeightOut(double weightOut, double weightIn)用两个参数声明,你用无参数调用它。 Hence the error. 因此错误。

WeightOut()  

expects two parameters. 期望两个参数。 But why ? 但为什么 ? You don't use them. 你不使用它们。

Rewrite your method without the 2 parameters 在没有2个参数的情况下重写您的方法

public double WeightOut()
{
   return 0.13;
}

You probably want to change 你可能想改变

public override double WeightOut(double weightOut, double weightIn)
{
    return 0.13;
}

to

public override double WeightOut()
{
    return 0.13;
}

as you aren't using the parameters. 因为你没有使用参数。

also why the override? 还为什么覆盖? May need to remove that if removing the parameters causes another syntax error, or fix it in the base class as well. 可能需要删除它,如果删除参数导致另一个语法错误,或者也在基类中修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM