Simagen
Simagen

Reputation: 419

no overload for method 'METHOD' takes 0 arguments

I have 3 methods.

1 method holding the value of 3000 1 method holding the value of 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:

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

Upvotes: 4

Views: 9206

Answers (4)

Claudio Redi
Claudio Redi

Reputation: 68410

WeightOut expect 2 parameters and you're not providing them

Upvotes: 13

Gonzalo.-
Gonzalo.-

Reputation: 12672

WeightOut()  

expects two parameters. But why ? You don't use them.

Rewrite your method without the 2 parameters

public double WeightOut()
{
   return 0.13;
}

Upvotes: 5

Kevin DiTraglia
Kevin DiTraglia

Reputation: 26068

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.

Upvotes: 3

Brian Rasmussen
Brian Rasmussen

Reputation: 116411

WeightOut(double weightOut, double weightIn) is declared with two parameters and you're calling it with none. Hence the error.

Upvotes: 5

Related Questions