??
格式化金额
10000000 -> 1000,000,0
public string FormatAmount(decimal? amount = null) { amount = amount ?? Amount; var s = amount.ToString(); if (s.Length < 2) { return s; } var len = s.IndexOf(‘.‘); if (len < 0) { len = s.Length; } if (len < 4) { return s; } for (var i = 1; i < len; i += 3) { s = s.Insert(i, ","); i++; len++; } return s; }
时间: 2024-10-07 02:06:05