Setting MidpointRounding.AwayFromZero as the default rounding method
I am making an application and I need to round the numbers ALWAYS using MidpointRounding.AwayFromZero but every time I do rounding I have to write the following statement
Math.Round(xxx, ddd, MidpointRounding.AwayFromZero);
Is there a way to set the default path for MidpointRounding.AwayFromZero to the Math.Round (...) method?
+3
source to share
1 answer
Is there a way to set the default path for MidpointRounding.AwayFromZero to the Math.Round (...) method?
No no.
But you can write a helper method that you use wherever it is used MidpointRounding.AwayFromZero
.
public static class MathHelper
{
public static double Round(double value, int digits)
{
return Math.Round(value, digits, MidpointRounding.AwayFromZero);
}
}
+6
source to share