处理金额小数点后的零

比较低级,但是使用没问题
处理金额小数点后的零
 1   public static decimal DealLoanmoney(string loanmoney)

 2         {

 3             int zhengshu =Convert.ToInt32(loanmoney.Split('.')[0]);

 4             string weishu = loanmoney.Split('.')[1];

 5             int i = 0;

 6             for (int a = weishu.Length-1; a >= 0; a--)

 7             {

 8                 if (weishu[a] != '0')

 9                 {

10                     i = a+1;

11                     break;

12                 }

13             }

14             string ws = weishu.Substring(0,i);

15             return Convert.ToDecimal(zhengshu) +Convert.ToDecimal("0."+ws);

16         }
View Code

 

你可能感兴趣的:(处理)