C#使用Math.Round("数值","保留位","保留方式")进行小数位保留以及四舍五入
//1.MidpointRounding.ToEven(四舍六入五成双)
//当保留小数位后一位为0~4时,舍去末位
var x1 = Math.Round(1.124, 2, MidpointRounding.ToEven); //1.12
//当保留小数位后一位为6~9时,进位
var x2 = Math.Round(1.126, 2, MidpointRounding.ToEven); //1.13
//当保留小数位后一位为5时,5后不为0外进位
var x3 = Math.Round(1.12501, 2, MidpointRounding.ToEven); //1.13
//当保留小数位后一位为5时,5后为0,5前一位为奇数时,进位
var x4 = Math.Round(1.135, 2, MidpointRounding.ToEven); //1.14
//当保留小数位后一位为5时,5后为0,5前一位为偶数时,不进位
var x5 = Math.Round(1.125, 2, MidpointRounding.ToEven); //1.12
//2.MidpointRounding.AwayFromZero (四舍五入)
//当小数位保留位后一位为0~4时,不进位
var x6 = Math.Round(1.1241, 2, MidpointRounding.AwayFromZero);//1.12
//当小数位保留位后一位为5~9时,进位
var x7 = Math.Round(1.1251, 2, MidpointRounding.AwayFromZero);//1.13
PS:保留方式为空时,默认的是 MidpointRounding.ToEven