金额类型转换

首先把金额转换为decimal类型

取四舍五入值后的结果,例如:

 ->.toString("n");为1,000,000

->.toString("C");为¥1,000,000

 1  /// <summary>
 2     /// 对金额进行四舍五入
 3     /// </summary>
 4     /// <param name="dd"></param>
 5     /// <returns></returns>
 6     public string MathRound(string dd)
 7     {
 8         if (!string.IsNullOrEmpty(dd))
 9         {
10             dd = Math.Round(Convert.ToDecimal(dd)).ToString("C");
11             string[] dds = dd.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
12             return dds[0];
13         }
14         else
15         {
16             return "";
17         }
18     }
原文地址:https://www.cnblogs.com/dongbo19910728/p/3138544.html