I am bit confused as to why calling Math.Round method would raise, “Ambiguous Call” compiler error.
Here is my offending code:
Math.Round((2000-((Splots[x].RawMin/4095)*2000))+200);
RawMin is Int32 data type.
I thought, Round method should return with Int32 value type.
Any hints or clues will be greatly appreciated. Thanks,
Look at the overload list for
Math.Round. There are two methods taking a single parameter:Both are applicable when called with an
intargument – but it’s pointless to call the method when you’ve only got anintto start with, as it’s already rounded.I suspect you actually want to change how you’re doing arithmetic, e.g. by performing the division operation in
doublearithmetic, which will then propagate to the other operations:Without that, all the operations use integer arithmetic, which almost certainly wasn’t what you wanted.
You’ll still need to cast the result to
intthough. The range ofdoubleexceeds that of bothintandlong, which is why the return type ofMath.Round(double)isdouble. In this case you “know” that the result will be in an appropriate range though, given the calculation.