Decimal类型的值处理为财务的四舍五入,保留2位小数,不足补0的处理
//Decimal类型的值处理为财务的四舍五入,保留2位小数,不足补0的处理
public static string op_moneyx(this Decimal x)
{
string str = string.Concat((object) Math.Round(x, 2, MidpointRounding.AwayFromZero));
if (!str.Contains("."))
return str + ".00";
if (str.Split('.')[1].Length != 2)
str += "0";
return str;
}
记录一下该代码片段方便后续Copy.

浙公网安备 33010602011771号