User1940134294 posted
It seems that you are using the float data type that’s why you are not getting the desired result.
If you use double data type it will provide you the required result.
float a = 3.145f;
Math.Round(a, 2, MidpointRounding.AwayFromZero);
Output
3.14
double a = 3.145;
Math.Round(a, 2, MidpointRounding.AwayFromZero);
Output
3.15
It happens because when you convert from float to double you will not get the exact data.
e.g.
float a = 3.145f;
double b = Convert.ToDouble(a); Write(b);
value of b: 3.14499998092651
you can see that the value is not exactly same when converting from float to double. that's why you may get undesired result.