No overload for METHOD method takes 0 arguments

I have 3 methods.

1 method containing a value of 3000 1 while holding a value of 0.13

and I created another method that I want to multiply by these two digits.

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 get a syntax error in WeightOut here:

 public override int HowMuchTheFishWeighOutKG() { return (FishPerTank() * WeightOut()); } 
+4
source share
4 answers

WeightOut expect 2 parameters and you do not provide them

+13
source

WeightOut(double weightOut, double weightIn) declared with two parameters, and you call it with nothing. Hence the error.

+5
source
 WeightOut() 

expects two parameters. But why? You do not use them.

Rewrite your method without two parameters

 public double WeightOut() { return 0.13; } 
+5
source

You might want to change

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

to

 public override double WeightOut() { return 0.13; } 

since you are not using parameters.

also why redefinition? You may need to remove this if deleting the parameters causes another syntax error or correct it in the base class.

+3
source

All Articles