对数值保存两位小数,有时是整数时,不需要显示两位小数。例如值为:1.32 保留两位,结果是1.32,值为:2,结果有两种显示,2和2.00
/// <summary> /// 金额 /// </summary> public decimal tax_amount { get; set; } /// <summary> /// 如是整数,则直接显示整数 /// </summary> public string tax_amountFormat { get { return tax_amount.ToString("0.##"); } } /// <summary> /// 如是整数,则后面会有两位小娄,如2.00 /// </summary> public string tax_amountFormat2 { get { return tax_amount.ToString("0.00"); } } /// <summary> /// 如是整数,则后面会有两位小娄,如2.00 /// </summary> public string tax_amountFormat3 { get { return tax_amount.ToString("f2"); } }