比较低级,但是使用没问题
public static decimal DealLoanmoney(string loanmoney) { if (loanmoney.Contains(".")) { int zhengshu = Convert.ToInt32(loanmoney.Split('.')[0]); string weishu = loanmoney.Split('.')[1]; int i = 0; for (int a = weishu.Length - 1; a >= 0; a--) { if (weishu[a] != '0') { i = a + 1; break; } } string ws = weishu.Substring(0, i); return Convert.ToDecimal(zhengshu) + Convert.ToDecimal("0." + ws); } else { return Convert.ToDecimal(loanmoney); } }