I'm doing an app and I need to round the numbers ALWAYS using the MidpointRounding.AwayFromZero but every time I do the rounding I've to write the following statement
Math.Round(xxx, ddd, MidpointRounding.AwayFromZero);
Is there a way to set the MidpointRounding.AwayFromZero to the default way to the method Math.Round(...)?
Is there a way to set the MidpointRounding.AwayFromZero to the default way to the method Math.Round(...)?
No, there isn't.
But you can write a helper method that you use everywhere which uses MidpointRounding.AwayFromZero.
public static class MathHelper
{
public static double Round(double value, int digits)
{
return Math.Round(value, digits, MidpointRounding.AwayFromZero);
}
}
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