No overload for method ‘WeightOut’ takes 2 arguments
My code was working before I tweaked it to make it more efficient.
this is the working code:
In the BASE class I have:
public virtual double WeightOut(double weightOut, double wightIn)
{
return Math.Round((weightOut = (weightIn + 0.12)), 2);
}
Then in the INHERITED class I have:
public override double WeightOut(double weightOut, double weightIn)
{
return Math.Round((this.WeightIn() + 0.12), 2);
}
Then I changed it so that I am not using the same code in both classes and rather only in the inherited class as so:
In the BASE class:
public abstract double WeightOut();
In the INHERITED class:
public override double WeightOut()
{
return Math.Round((this.WeightIn() + 0.12), 2);
}
I then got the syntax error when compiling with this line of code that leads from the WeightOut() method in the same INHERTIED class:
public override double HowMuchTheFishWeighOutKG()
{
return this.FishPerTank() * this.WeightOut(0, 0) * this.Tanks();
}
so I then changed it to:
public override double HowMuchTheFishWeighOutKG()
{
return this.FishPerTank() * this.WeightOut() * this.Tanks();
}
The syntax error still stands:
No overload for method ‘WeightOut’ takes 2 arguments.
(ANOTHER SMALLER PROBLEM)
It tells me where the error is: 37,59
but Visual Studio does not show me where that is, and I will have to count myself to find where it is.
A few things I would check:
In the base class, are you certain that the abstract method for WeightOut has NO parameters. The complaint being issued could have something to do with a mis-match from the inherited function definition.
Second thing to check, Right Click on the Inherited Classes “WeightOut” function (the function name specifically) and select the option
Find All References. This should give you a list of every place in the code, by class name/filename and line number, that calls this function. That might help.Note: if you dont have that option, please elaborate which version of Visual Studio you are using?
Also Note: this can be done with a “Find in Files” search as well for the function name. This search will return more false positives, but will still locate all references to the function.
Also, even in vs 2005, if you double click the error in the Errors box, it should put your cursor on the line that is causing an issue, or rather the line that is throwing the error, if its not a code line but instead is like a closing
}, then that tells us something different.