public static decimal Round(
decimal d,
int decimals
)
The decimals parameter specifies the number of fractional digits in the return value and ranges from 0 to 28. If decimals is zero, an integer is returned.
If the value of the first digit in d to the right of the decimals decimal position is 5, the digit in the decimals position is rounded up if it is odd, or left unchanged if it is even. If the precision of d is less than decimals, d is returned unchanged.
Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Why 3.45 is returning 3.4..I am unable to understand this output.Can anyone help
You can change this behaviour by using the Round overload which take the MidpointRounding parameter, from MSDN:
ToEven (default, AKA Bankers Rounding) When a number is halfway between two others, it is rounded toward the nearest even number.
AwayFromZero When a number is halfway between two others, it is rounded toward the nearest number that is away from zero.