I'm trying to overload a method in C# with the same number of parameters but different types.
private double scale(double value)
{
return value * 100 / scale;
}
private float scale(float value)
{
return value * 100 / scale;
}
but I get this error
Error 4 The type '[className]' already contains a definition for 'scale'
NOTE: I'm working in MVS 2008
Thank you.
This code doesn't make sense:
return value * 100 / scale;
If you have a method name scale, then what does the scale at the end of the line do?
Your Method Signature is semantically correct, as this is perfectly legal C# code:
private float scale(float input)
{
return input;
}
private double scale(double input)
{
return input;
}
It seems that you also have a field or property named scale in your class:
private float scale = 0.15f;
To me it's complaining about the scale that you are using as a variable. You can have something like this
private double scale1 = 0.0d;
private double scale(double value)
{
return value * 100 / scale1;
}
private float scale(float value)
{
return (float) (value * 100 / scale1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With